Object ID in query_store_query DMV doesn't exist? Where'd it go?

Michael MacGregor 86 Reputation points
2021-03-19T18:09:55.577+00:00

I'm querying the query store DMVs directly but the object_id in the query_store_query DMV is returning a value that can't be found. It isn't 0 so why does it return a value that doesn't seem to exist? Could this be due to the fact some queries are coming from Entity Framework and is creating temporary objects? Clutching at straws here. Any help is appreciated.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,756 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,554 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 101.4K Reputation points MVP
    2021-03-19T22:49:09.943+00:00

    An obvious reason is that the object in question have been dropped. But I don't think Entity Framework creates temporary objects.

    Something I haven't tested, but what if there is a query that calls a function in a different database? How is this recorded? (If you make a call to a stored procedure in a different database, I would expect that call to be recorded in Query Store for that database.)

    0 comments No comments

  2. Michael MacGregor 86 Reputation points
    2021-03-20T00:25:46.413+00:00

    You'd think it was obvious, eh, but this was after load testing on the database in question, with no changes to either tables, stored procs, UDFs, etc. No cross-database functionality at all.

    It's left me scratching my head as to what's going on.

    0 comments No comments

  3. Erland Sommarskog 101.4K Reputation points MVP
    2021-03-20T10:13:25.547+00:00

    Maybe you should re-run the load test, but now with a DDL triggers that logs eventdata()? to a table?

    When you look up a plan in sys.dm_exec_plan_attributes, you will find an objectid also for ad-hoc queries, which is the internal hash of the query text. However, I don't think think this hash is saved to Query Store, and nor does the documentation suggest that this is the case.

    0 comments No comments