Re: Initial queries of day slow

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Rebecca Clarke *EXTERN*" <r(dot)clarke83(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Initial queries of day slow
Date: 2014-04-07 09:50:16
Message-ID: A737B7A37273E048B164557ADEF4A58B17CEBEA9@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rebecca Clarke wrote:
> I'm a bit stumped. At present I'm finding that queries to my database, that normally execute promptly,
> are taking a long time when they are executed first thing in the morning (after the database has been
> inactive for several hours). After the first execution, everything is back to normal.
>
> A while back I turned autovacuum off and now instead I run a daily cron at 3am that executes a script
> which does a VACUUM ANALYZE on each table.

It could be that during the day the necessary pages are cached in
the buffer pool or the file system cache, but have dropped out of
the cache during the night.

Try EXPLAIN (ANALYZE, BUFFERS) SELECT ...
first thing in the morning and during the day and compare the
"shared read" and "shared hit" values.

It may well be the nightly VACUUM ANALYZE that does that - is autovacuum
not doing ist job for you?
Is there anything else going on on the machine during the night, like
backups or batch jobs?

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message howardnews@selestial.com 2014-04-07 10:04:23 Order By and Comparisson
Previous Message Nithya Soman 2014-04-07 09:46:18 How do you find the row count for all your tables in Postgres?