pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-performance@postgresql.org
To: Doug Eck <deck1@yahoo.com>
Subject: Re: I/O on select count(*)
Date: Wed, 14 May 2008 17:11:21 -0500
Message-ID: <482B1D5F.EE98.0025.0@wicourts.gov> (raw)
In-Reply-To: <920841.71690.qm@web44808.mail.sp1.yahoo.com>
References: <920841.71690.qm@web44808.mail.sp1.yahoo.com>

>>> Doug Eck <deck1@yahoo.com> wrote: 
 
> I am attempting to run a query to determine the number of rows for a
given 
> day using something like "select count(*) from tbl1 where ts between

> '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'".  Explain
tells me 
> that the query will be done using an index scan (as I would expect),
and I 
> realize that it is going to take a while.  My question concerns some
unusual 
> I/O activity on the box (SUSE)  when I run the query.
> 
> For the first couple of minutes I see reads only.  After that vmstat
shows 
> mixed reads and writes in a ratio of about 1 block read to 5 blocks
written.  
 
> Any thoughts into what could be going on?  Thanks in advance for your
help.
 
Odd as it may seem, a SELECT can cause a page to be rewritten.
 
If this is the first time that the rows are being read since they were
inserted (or since the database was loaded, including from backup), it
may be rewriting the rows to set hint bits, which can make subsequent
access faster.
 
The best solution may be to vacuum more often.
 
http://archives.postgresql.org/pgsql-performance/2007-12/msg00206.php
 
-Kevin
 




view thread (54+ messages)  latest in thread

Message-ID: <482B1D5F.EE98.0025.0@wicourts.gov>
Permalink:  ../482B1D5F.EE98.0025.0@wicourts.gov/
Also on:    postgresql.org/message-id/482B1D5F.EE98.0025.0@wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, deck1@yahoo.com
  Subject: Re: I/O on select count(*)
  In-Reply-To: <482B1D5F.EE98.0025.0@wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox