Efcore: ToQueryPlan to... get the query plan...

Created on 28 Oct 2020  路  4Comments  路  Source: dotnet/efcore

Very cool idea suggested by @lauxjpn: we now have ToQueryString, we could also get the query plan from the database.

SQL Server:

SET SHOWPLAN_ALL ON;
<query>
SET SHOWPLAN_ALL OFF;

PostgreSQL / SQLite

EXPLAIN <query>
area-perf area-query needs-design type-enhancement

Most helpful comment

Also not all users have showplan rights with SQL Server..

All 4 comments

When this has been implemented, this basically screams for an extension, that allows users to specify execution duration limits, that will log the query together with the query plan, once those limits get hit.

We may as well just find out what's wrong with the queries and fix it too :rofl:

Seriously, this is a really nice direction.

This has challenges that ToQueryString doesn't have--most notably that it requires a connection to the database to run the "explain" query. So this probably needs a bit more thought, but integrating this in some way with EF Core would be very useful.

Also not all users have showplan rights with SQL Server..

Was this page helpful?
0 / 5 - 0 ratings