Re: index and queries using '<' '>'

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Marc Boucher <pgml(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: index and queries using '<' '>'
Date: 2004-11-19 14:16:48
Message-ID: 20041119141648.GA22737@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Nov 19, 2004 at 14:45:04 +0100,
Marc Boucher <pgml(at)gmx(dot)net> wrote:
> At 16:23 18/11/2004 +0100, Martijn van Oosterhout wrote:
> > The system seems to think that a scan is cheap because the table is so
> > small.
> The table currently contains just over 10000 elements. So 238 rows is a
> small part of it.

No, small is typically less than 1%. This depends on the size of the rows
and how much better accessing disk blocks sequentially is in your
enviroment and the size of your cache.

Because your table is so small it will probably all be cached after being
read through once, so you may want to tune your config settings to
say than random disk access costs only a little more than sequential
access. However, you need to be careful if your table is going to grow
a lot larger.

> Since the table is still growing, and the amount of rows in the reply of
> the query is quite uniform (it's not dependant on the size of the table), I
> hope that the statistics will evolve in a state that will force the use of
> the index.

Index scans aren't always faster than sequential scans.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc Boucher 2004-11-19 14:47:21 Re: index and queries using '<' '>'
Previous Message Marc Boucher 2004-11-19 13:45:04 Re: index and queries using '<' '>'