Re: Re: quick question: index optimisations on small tables - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Re: quick question: index optimisations on small tables
Date
Msg-id Pine.BSF.4.21.0108301706040.55734-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Re: quick question: index optimisations on small tables  ("Andrew Snow" <andrew@modulus.org>)
List 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)



pgsql-general by date:

Previous
From: "G.L. Grobe"
Date:
Subject: query help
Next
From: Stephan Szabo
Date:
Subject: Re: query help