Skip to content
Advertisement

How do I process execution plan in PostgreSQL?

In PostgreSQL, when I run:

I get:

How can I get the “Total Cost” from there? I tried:

But I get the error:

Advertisement

Answer

explain always needs to go before a statement, you can’t put it in the middle of one.

You can do what you want by wrapping this into a function:


If you can’t use a function, you can use an anonymous block with a RAISE statement:

But that seems overly complicated compare to using:

And then simply looking at the first line.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement