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

From: Patrick B <patrickbakerbr(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: How to evaluate "explain analyze" correctly after "explain" for the same statement ?
Date: 2017-02-15 23:58:37
Message-ID: CAJNY3ivJ+Gw_2fWjkOnbU7EZqLT8G=KNwkGt8yJxEw9mRAV0Zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Probably the statement is cached, right?

So, I do (To clear the cache):

- service postgresql stop
- echo 3 > /proc/sys/vm/drop_caches
- service postgresql start

But, then, executing the statement again, it runs in 0.8 ms.

How can I clean the cache to get the REAL runtime for that statement?
Thanks
Patrick

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andres Freund 2017-02-16 00:15:11 Re: Potential Bug: Frequent Unnecessary Degeneration
Previous Message David O'Mahony 2017-02-15 23:30:11 Potential Bug: Frequent Unnecessary Degeneration