On my Query Store presentation on Windays 2017 conference I had a interesting question I decided to write a blog about. The question was where is the query stored when query uses linked server?
My setup is the following:
- ServerA – DatabaseA – query store on, Capture Mode All
- ServerB – DatabaseB – query store on, Capture Mode All
- Linked Server on ServerA – [ServerB]
First query is executed on ServerA and looks like this:
select * from [ServerB].DatabaseB.TableB
The query was recorded in DatabaseA query store. As expected.
Second query is executed on ServerA as pass-through query and looks like this:
select * from OPENQUERY ([ServerB], ‘select * from DatabaseB.TableB’) t
I expected the query to be recorded in DatabaseA and DatabaseB, but the query was only recorded in Database A.