Re: Indeces vs small tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Francisco Reyes <lists(at)natserv(dot)com>
Cc: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Indeces vs small tables
Date: 2001-08-05 20:35:11
Message-ID: 4005.997043711@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Francisco Reyes <lists(at)natserv(dot)com> writes:
> For small tables, less than 100 rows, does it pay off to have an index?

The planner is of the opinion that it doesn't ;-)

The planner's cost model says that disk fetches cost way more than
comparison operations, so an index is unlikely to be considered
profitable unless scanning it saves more fetches than it costs.
If the table is only a couple of disk pages in size, there's no
way that doing the extra I/O to read an index (also a couple of
pages) can pay for itself.

On a really heavily used table, this cost model might break down
because the pages would all remain in shared memory anyway. But
that's how the planner will bet, so you'd have to go out of your
way to persuade it to use the index.

My take on it is that for such a small table, it hardly matters
which plan is chosen...

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message harrold 2001-08-05 20:55:59 nextval/dbi question
Previous Message Francisco Reyes 2001-08-05 20:30:10 select vs varchar