pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: hsienwen chu <chu.hsien.wen@gmail.com>
To: pgsql-admin@postgresql.org
Subject: Re: Question about the IO on full table scan operation
Date: Wed, 06 Oct 2010 15:27:55 -0500
Message-ID: <4CAC957B02000025000365D8@gw.wicourts.gov> (raw)
In-Reply-To: <AANLkTi=pYV8MfHt56tPxFFyJBU6=RCRS6ruKidie3es8@mail.gmail.com>
References: <AANLkTi=pYV8MfHt56tPxFFyJBU6=RCRS6ruKidie3es8@mail.gmail.com>

hsienwen chu <chu.hsien.wen@gmail.com> wrote:
 
> the situation is that: I have a table, and the size is about 10M,
> I run the database on Redhat Linux platform. for OS, a IO can hand
> 1M data, the file system block is 4k, database block is 8k,
> 
> my question is that: when do the full table scan on the table, how
> many IO will be done? 10M/1M=10 ? or 10M/8k=1280? or 10M/4k=2560?
 
Well, it will be looking at one 8kB block at a time, but the number
of I/O operations to the actual disk is hard to estimate and may
vary from run to run, especially if another table scan is going on
at the same time.
 
Some pages may be found in shared buffers, and therefore generate no
disk access.  PostgreSQL reads go through the OS cache, so some
pages may be found there, and generate no disk access.  Most serious
database servers have a RAID controller with a cache, which may also
avoid disk access.  You might even read from a write-through cache
on a drive without actually going to the disk.
 
On top of that, many operating systems will notice a pattern of
sequential reads through a file and do larger block read-ahead
access for performance.  And PostgreSQL has its own tricks -- if you
start a sequential table scan while another process is already doing
one, your scan will start where the other one is, to avoid
double-reads.
 
About all I can say with any certainty is that it *won't* be doing
10M/4k=2560 reads.  And even there I won't be too surprised if
someone corrects me with an explanation of then *that* might happen.
 ;-)
 
-Kevin



view thread (2+ messages)

Message-ID: <4CAC957B02000025000365D8@gw.wicourts.gov>
Permalink:  ../4CAC957B02000025000365D8@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4CAC957B02000025000365D8@gw.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, chu.hsien.wen@gmail.com
  Subject: Re: Question about the IO on full table scan operation
  In-Reply-To: <4CAC957B02000025000365D8@gw.wicourts.gov>
  References: <AANLkTi=pYV8MfHt56tPxFFyJBU6=RCRS6ruKidie3es8@mail.gmail.com> <4CAC957B02000025000365D8@gw.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