Re: Re: quick question: index optimisations on small tables

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Andrew Snow <andrew(at)modulus(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: quick question: index optimisations on small tables
Date: 2001-08-31 00:08:31
Message-ID: Pine.BSF.4.21.0108301706040.55734-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Fri, 31 Aug 2001, Andrew Snow wrote:

> Hrmm... I have 26 rows in mine at the moment, and after vacuum
> analyzing, it uses a seq. scan. How come yours used the index? I
> thought mine wasn't using an index because postgres won't use an index
> until the table is "big enough".
>
> But if an index page is already in cache.. surely it'd be faster using
> it than doing a seq. scan.
>
> (Yes, I know its a small table, but I think the worst case for seq. scan
> would be a fair bit worse than for the index, and every little bit
> counts, right?)

If the table is small enough to fit in one page, a sequence scan across
those rows may be faster than the index scan since the index scan will
need to read two pages (one for the index, one for the heap -- the
visibility info is only in the heap so that must be consulted for
each index match)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-08-31 00:22:09 Re: query help
Previous Message G.L. Grobe 2001-08-30 23:45:20 query help