pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: excalibur@hub.org
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Some very weird behaviour....
Date: 09 Jul 2003 17:42:35 +0000
Message-ID: <1057772554.46100.103.camel@jester> (raw)
In-Reply-To: <1057771777.33712.98.camel@freebsd47>
References: <1057771777.33712.98.camel@freebsd47>

>  To give you some perspective on the size of the dataset and the
> performance level we are hitting, here are some "good" results based on
> some explains:

Before Tom jumps in taking all the fun out of trying to solve it...


The estimates in the slow queries seem perfectly reasonable.  In fact,
the cost estimates of both the slow and fast queries are the same which
is what would be expected if all of the data was distributed evenly
amongst the table.

Given it's a date, I would guess that the data is generally inserted
into the table in an order following the date but for some reason those
'high' dates have their data distributed more evenly amongst the table. 
Clustered data will have fewer disk seeks and deal with fewer pages of
information in general which makes for a much faster query.  Distributed
data will have to pull out significantly more information from the disk,
throwing most of it away.

I would guess that sometime on 2002-05-25 someone did a bit of data
cleaning (deleting records).  Next day the free space map had entries
available in various locations within the table, and used them rather
than appending to the end.  With 89 Million records with date being
significant, I'm guessing there aren't very many modifications or
deletes on it.

So.. How to solve the problem? If this is the type of query that occurs
most often, you do primarily inserts, and the inserts are generally
created following date, cluster the table by index "some_table_ix_0". 
The clustering won't degrade very much since that is how you naturally
insert the data.

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (3+ messages)  latest in thread

Message-ID: <1057772554.46100.103.camel@jester>
Permalink:  ../1057772554.46100.103.camel@jester/
Also on:    postgresql.org/message-id/1057772554.46100.103.camel@jester

 · 

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: rbt@rbt.ca, excalibur@hub.org
  Subject: Re: Some very weird behaviour....
  In-Reply-To: <1057772554.46100.103.camel@jester>
  References: <1057771777.33712.98.camel@freebsd47> <1057772554.46100.103.camel@jester>

* 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