Skip site navigation (1) Skip section navigation (2)

Re: Query timing stable?

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Query timing stable?
Date: 2012-03-14 18:32:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On 03/14/2012 11:24 AM, Cheng wrote:
> Hi,
> I turned on "\timing" in the command line. It seems that the timing is 
> not stable. For the same query, the query's executing time is longer 
> for the first time I run it than for the second and third time run it. 
> I think it might be "cached" automatically.
> Is there a way to turn the "automatic caching" off so that I can get 
> the same "timing" when I run the same query? Or is there some other 
> way to get stable query time whenever the query is run?
> Thanks,
> Cheng

Depends on your OS. Things almost always run faster on subsequent access 
- usually due to OS caching of disk reads but data can be cached in 
PostgreSQL and your storage subsystems as well.

Ensuring that *everything* is flushed almost requires restarting your 
system. Depending on your OS, you may be able to flush the disk cache 
and restart PostgreSQL and get "close enough".

Depending on your query, you may be altering the underlying tables so 
getting exact repeatability is unlikely.


In response to

pgsql-novice by date

Next:From: LewDate: 2012-03-15 14:04:21
Subject: Re: QUERY
Previous:From: ktm@rice.eduDate: 2012-03-14 18:30:58
Subject: Re: Query timing stable?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group