Re: Help: how to speed up query after db server reboot

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Wei Yan <weiyan1(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Help: how to speed up query after db server reboot
Date: 2009-09-03 14:32:04
Message-ID: 14128.1251988324@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Wed, Sep 2, 2009 at 00:01, Wei Yan<weiyan1(at)gmail(dot)com> wrote:
>> Looks like after postgres db server reboot, first query is very slow
>> (10+mins). After the system cache built, query is pretty fast.
>> Now the question is how to speed up the first query slow issue?

> Schedule a run of a couple of representative queries right as the
> database has started? That should pre-populate the cache before your
> users get there, hopefully.

I wonder if VACUUMing his key tables would be a good answer. I bet that
a lot of the problem is swapping in indexes in a slow random-access
fashion. In recent-model Postgres, VACUUM will do a sequential scan of
the indexes (at least for btree) which should be a much more efficient
way of bringing them into kernel cache.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2009-09-03 14:49:36 Re: partition query using Seq Scan even when index is present
Previous Message Tguru 2009-09-03 13:52:53 Re: SAAS and MySQL