Re: Different execution time for same plan

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <nickrajjain(at)gmail(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Different execution time for same plan
Date: 2011-06-06 15:48:49
Message-ID: 4DECB091020000250003E1D8@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

First off, this is posted to the wrong list -- this list is for
discussion of development of the PostgreSQL product. There is a
list for performance questions where this belongs:
pgsql-performance(at)postgresql(dot)org(dot) I'm moving this to the
performance list with a blind copy to the -hackers list so people
know where the discussion went.

Nick Raj <nickrajjain(at)gmail(dot)com> wrote:

> When i execute the query first time, query takes a quite longer
> time but second time execution of the same query takes very less
> time (despite execution plan is same)

> Why the same plan giving different execution time? (Reason may be
> data gets buffered (cached) for the second time execution) Why
> there is so much difference?

Because an access to a RAM buffer is much, much faster than a disk
access.

> Which option will be true?

It depends entirely on how much of the data needed for the query is
cached. Sometimes people will run a set of queries to "warm" the
cache before letting users in.

> MY postgresql.conf file having setting like this (this is original
> setting, i haven't modify anything)

> shared_buffers = 28MB

> #work_mem = 1MB # min 64kB
> #maintenance_work_mem = 16MB # min 1MB

If you're concerned about performance, these settings (and several
others) should probably be adjusted:

http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

-Kevin

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-06-06 15:50:34 Re: reducing the overhead of frequent table locks - now, with WIP patch
Previous Message Heikki Linnakangas 2011-06-06 15:48:42 Re: BLOB support

Browse pgsql-performance by date

  From Date Subject
Next Message Mike Broers 2011-06-06 20:35:04 poor performance when recreating constraints on large tables
Previous Message Heikki Linnakangas 2011-06-06 09:47:10 Re: Index use difference betweer LIKE, LIKE ANY?