Re: Optimizing further

From: Doug Fields <dfields-pg-general(at)pexicom(dot)com>
To: Ken Williams <ken(at)mathforum(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimizing further
Date: 2002-06-14 03:08:16
Message-ID: 5.1.0.14.2.20020613230619.02b81038@pop.pexicom.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>When I run the query, it takes a really long time (10 seconds) the first
>time I execute it, and then returns instantly the second time.

This is behavior which I often encounter with my databases as well (and I
have 8 gigs of RAM now), and is easy to explain.

The first time, the system has to page in all the necessary data from the
disk. This is slow.

The second and subsequent times, the pages are in memory (either in the
shared_mem segment or the OS disk cache) and hence the query runs extremely
quickly.

Of course, if you run a different query which requires other page loads in
the interim, and those page loads cause the other pages to be flushed, the
next time this query runs it will be slow again.

Cheers,

Doug

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-06-14 03:27:06 Re: Contrib reindex script:
Previous Message Tom Lane 2002-06-14 03:03:14 Re: Optimizing further