Giter Site home page Giter Site logo

giorgi / linqpad.queryplanvisualizer Goto Github PK

View Code? Open in Web Editor NEW
391.0 22.0 29.0 1.23 MB

SQL Server and PostgreSQL query execution plan visualizer for LINQPad

Home Page: https://www.giorgi.dev/miscellaneous/introducing-linqpad-queryplanvisualizer/

License: Other

C# 67.67% CSS 7.12% XSLT 23.28% HTML 1.94%
linqpad nuget sql-server postgresql npgsql efcore linqpad-plugin

linqpad.queryplanvisualizer's Introduction

LINQPad.QueryPlanVisualizer

Visualize Entity Framework and Linq to SQL queries in LINQPad. For Visual Studio extension see EFCore.Visualizer

NuGet Package GitHub all releases Apache License Ko-Fi

Entity Framework Community Standup Live Show

Entity Framework Community Standup - Entity Framework Community Standup - Visualizing database query plans

SQL Server and PostgreSQL query execution plan visualizer for LINQPad

Features

Supported databases: Sql Server and PostgreSQL.

Supported ORMs: Entity Framework Core 5 and LINQ to SQL

Getting Started

If you use LINQPad 6 or newer, you must use version 2.X of this library. For LINQPad 5, you must use version 1.X

Version 2.1 and newer uses Microsoft Edge WebView2 to display the query plan. This requires either WebView2 Runtime to be installed or a recent version of Edge Canary. To download WebView2 Runtime visit Microsoft Edge WebView2 Download Page.

Install from NuGet

If you have a Developer or higher edition of LINQPad, you can use the LINQPadQueryPlanVisualizer package from NuGet to add the visualizer to your queries.

Install as plugin

To install the visualizer as a LINQPad plugin, download the latest release and drop the visualizer dll directly inside LINQPad's plugins folder (by default found at My Documents\LINQPad Plugins\NetCore3 for LINQPad 6 and My Documents\LINQPad Plugins\Framework 4.6 for LINQPad 5). The plugin will be automatically available in all your queries.

Viewing query plan

To view query plan or missing indexes, call static QueryPlanVisualizer.DumpPlan(query) method or call DumpPlan extension method on an IQueryable instance. You will also need to add ExecutionPlanVisualizer to the namespaces list (click F4 to open the dialog). If you want to dump query result as well, pass true as a second parameter.

Query execution plan for Sql Server:

Sql Server query plan

Query execution plan for PostgreSQL:

PostgreSQL query plan

Viewing missing indexes

For SQL Server, the query plan can also return information about missing indexes in QueryPlan/MissingIndexes/MissingIndexGroup element. If missing indexes are present in the plan the visualizer will show a second tab with the missing index details and a button to create the index.

Missing index:

missing indexes

What Others Are Saying

Scott Hanselman

Julie Lerman

Jeremy Likness

linqpad.queryplanvisualizer's People

Contributors

bio2hazard avatar bumbeishvili avatar giorgi avatar jared314 avatar mohadkamil avatar sgmoore avatar steveruble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linqpad.queryplanvisualizer's Issues

DumpPlan returns void

Firstly, thank you for this awesome LINQPad plugin!

I have a small nitpick, in that the DumpPlan extension method on IQueryable doesn't return the IQueryable, so one can't use it in Expression mode for example, unlike LINQPad's built in Dump methods.

Example:

TableName.Where(row => row.SomeValue > 1234).DumpPlan()

gives an error

CS0030 Cannot convert type 'void' to 'object'

No scrollbars

I immediately tried it on a large query and the plan is too big to fit even using "Full Screen Results", and there are no scrollbars to allow me to see the rest of the plan.

Cannot load WebView2 assembly

Hello,

I have an issue using the plugin.
It says it cannot load the WebView2 assembly.

image

System info:
Edition Windows 10 Pro
Version 21H1
Installed on ‎26/‎08/‎2021
OS build 19043.1237
Experience Windows Feature Experience Pack 120.2212.3530.0

image

In LINQPad the option to use Edge's Chromium engine to render results is checked.
image

Any idea?

Thank you.

xmlschemavalidationexception

Hello,
First of all, I would like to thank you for this great tool.
I have been trying to use but encountered this exception.

I do get results so the query is fine.
I get this exception for any query wrote. So i am posting just a simple one.

I searched about this exception but no success.
thanks!

linqpadexception

v1.1 doesn't like NoLock

With the previous build this worked:
Call SomeQuery.NoLock(Function(q)q.DumpPlan)

where NoLock is a MyExtension:

    public static void NoLock<T>(this IQueryable<T> query, Action<IQueryable<T>> expr)
    {
        using (var txn = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew,
            new TransactionOptions
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
            }))
        {
            expr(query);
        }
    }

Now this fails with an InvalidOperationException in the visualizer: https://onedrive.live.com/redir?resid=BED13F936EB1464C!105729&authkey=!AEQYbi5NFBcMfD0&v=3&ithint=photo%2cpng

(This is after adding EF, per the workaround mentioned in #10 .)

Getting 'Object reference not set to an instance of an object.' exception

I have a compiled context doing a simple query:

Profiles.Where( p => p.Client.cName == "AnnArbor" ).DumpPlan();

And it throws the exception. Not much information in the exception. Let me know what other information I can provide to help.

Trace:

at ExecutionPlanVisualizer.QueryPlanVisualizer.DumpPlan[T](IQueryable`1 queryable, Boolean dumpData)
at UserQuery
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Is the visual (graphic) output only available for SQL Server, not PostgreSQL?

Hi, thanks for this great plugin!

I just installed the package and noticed that when using PostgreSQL with LinqPad, the query execution plan output shows text instead of graphic. Then I noticed on your demo screenshots the PostgreSQL example seems to show the same thing. So I assume the nice visual graphic only works with SQL Server, correct?

Also for "missing index", will the plugin simply show the "missing index" tab if it finds them, and if the tab is not shown, we can assume there is no missing index?

XmlSchemaValidationException when using a `GroupBy`

 TimeEntries.Where(te => te.UserId == "43f25e47-3198-4f04-b4cc-691a29e2f939")
		 .SelectMany(te => te._WorkItemTags.Select(t => new { TimeEntry = te, Tag = t }))
		 .GroupBy(x => x.Tag.WorkItemId)
		 .DumpPlan(true)

image

EF 5 is not supported

Hi Giorgi,

I am escalating this to an issue of its own, rather than a comment to #4. Not sure you can solve this, as there is no interceptor for the DB commands in EF 5. Having said that, can we do without it, utilizing ToTraceString() for ObjectQuery/ToString() for DbQuery?

Attached is a DB-first DbContext EF 5 project/solution on top of AdventureWorks

DALForLinqPadVisualizerEF5.zip

Thanks, Boris

Make it compatible with LINQPad 6 (.NET Core version)

Right now while running in LINQPad 6 I'm getting:
FileNotFoundException: Could not load file or assembly 'LINQPad, Version=1.0.0.0, Culture=neutral, PublicKeyToken=21353812cd2a2db5'. The system cannot find the file specified.

image

Multiple requests for query plans should provide multiple visualizers

Connect to a Master database and run this query:

Tables.DumpPlan
'Util.ReadLine
Traces.DumpPlan

You only see the second plan, even if you uncomment the pause (because the plans are not displayed at all until the query is complete).

Whether this is a feature request or a bug depends on what was the original intention :-)

v1.1 requires EF

I allowed NuGet to update to the latest version and my query now fails with "Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."

AFAIK I haven't dealt with EF at all.

Query Plan Output tab does not respect windows scaling

Hey,

not sure how much can be done about this, but it'd be a great QOL improvement.

I have a 3200 x 1800 resolution screen and have windows scaling set to 175%. The query plan html output does not seem to respect that setting and is tiny. I can zoom in via ctrl + mouse wheel, but the zoom setting isn't saved, so as soon as a new query plan tab is created I have to zoom in again.

There is another problem with zooming in - it cuts off the bottom of the tooltip.

image

Again, not high priority by any means, but it would make it more usable.

Thank you for the great plugin.

Raw sql support

It would be nice to be able to have query plan for raw sql too
(for postgres at least ;) )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.