pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Claudio Freire <klaussfreire@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: Re: Adding additional index causes 20,000x slowdown for certain select queries - postgres 9.0.3
Date: Wed, 16 Mar 2011 14:42:07 -0500
Message-ID: <4D80CC3F020000250003B9BB@gw.wicourts.gov> (raw)
In-Reply-To: <AANLkTik3SfZih19i2svVX7BCxEOYkaGDGyzkovRrnZj3@mail.gmail.com>
References: <4D80B076020000250003B9B1@gw.wicourts.gov>
	<4D80B0AF020000250003B9B4@gw.wicourts.gov>
	<4D8102CC.5060309@peak6.com>
	<AANLkTi=zgp1bD-NTv000ZTC3MPM393msmRcB2e_YZ97-@mail.gmail.com>
	<AANLkTik3SfZih19i2svVX7BCxEOYkaGDGyzkovRrnZj3@mail.gmail.com>

Claudio Freire <klaussfreire@gmail.com> wrote:
 
> Forgive the naive question...
> but...
> 
> Aren't all index scans, forward or backward, random IO?
 
No.  Some could approach that; but, for example, an index scan
immediately following a CLUSTER on the index would be totally
sequential on the heap file access and would tend to be fairly close
to sequential on the index itself.  It would certainly trigger OS
level read-ahead for the heap, and quite possibly for the index.  So
for a lot of pages, the difference might be between copying a page
from the OS cache to the database cache versus a random disk seek.
 
To a lesser degree than CLUSTER you could get some degree of
sequencing from a bulk load or even from normal data insert
patterns.  Consider a primary key which is sequentially assigned, or
a timestamp column, or receipt numbers, etc.
 
As Tom points out, some usage patterns may scramble this natural
order pretty quickly.  Some won't.
 
-Kevin



view thread (15+ messages)  latest in thread

Message-ID: <4D80CC3F020000250003B9BB@gw.wicourts.gov>
Permalink:  ../4D80CC3F020000250003B9BB@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4D80CC3F020000250003B9BB@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-performance@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, klaussfreire@gmail.com
  Subject: Re: Adding additional index causes 20,000x slowdown for certain select queries - postgres 9.0.3
  In-Reply-To: <4D80CC3F020000250003B9BB@gw.wicourts.gov>
  References: <4D80B076020000250003B9B1@gw.wicourts.gov> <4D80B0AF020000250003B9B4@gw.wicourts.gov> <4D8102CC.5060309@peak6.com> <AANLkTi=zgp1bD-NTv000ZTC3MPM393msmRcB2e_YZ97-@mail.gmail.com> <AANLkTik3SfZih19i2svVX7BCxEOYkaGDGyzkovRrnZj3@mail.gmail.com> <4D80CC3F020000250003B9BB@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