Search Postgresql Archives

Re: How to evaluate "explain analyze" correctly after "explain" for the same statement ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Feb 15, 2017, at 3:58 PM, Patrick B <patrickbakerbr@xxxxxxxxx> wrote:
> 
> Hi all,
> 
> I just got a quick question about warm-cache. I'm using PG 9.2.
> 
> When I execute this statement soon after I start/restart the database:
> 
> explain select id from test where id = 124;
> 
> The runtime is 40ms.
> 
> Then, If I execute this statement just after the above one;
> 
> explain analyze select id from test where id = 124;
> 
> The runtime is 0.8ms.

This doesn't make seem to make sense.

"explain select ..." doesn't run the query. All it shows is the plan the planner chose and some estimates of the "cost" of different steps, with no time. Where are you getting 40ms from in this case?

"explain analyze select ..." does run the query, along with some - potentially non-trivial - instrumentation to measure each step of the plan, so you can see whether the planner estimates are reasonable or wildly off.

Cheers,
  Steve



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux