Re: index not being used

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Doug Fields <dfields-pg-general(at)pexicom(dot)com>
Cc: Reynard Hilman <reynardmh(at)lightsky(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: index not being used
Date: 2002-12-14 21:43:17
Message-ID: Pine.LNX.4.21.0212142141090.2585-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 14 Dec 2002, Doug Fields wrote:

> You're missing an analyze step: (see below)
>
> >here is the table structure:
> >create table test_10million (
> >id int8,
> >app_id int8
> >);
> >
> >< fill the table with 10 million record >
> >
> >create index test_10million_id on test_10million (id);
>
> ANALYZE test_10million;
>
> >this query always uses sequential scan:
> >select * from test_10million where id = 123 and app_id = 100;
>
> Now try
>
> explain select * from test_10million where id = 123 and app_id = 100;
>

Not forgetting of course that the numbers used in the tests will probably need
to be cast to int8 or quoted to make into text constants before the index is
used. I'm surprised the 1 million row test used the index. Unless this is in
7.3 and the behaviour has changed (which I can't remember about).

--
Nigel J. Andrews

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc 2002-12-14 21:55:34 Re: sourceforge move to DB2
Previous Message Doug Fields 2002-12-14 21:14:28 Re: index not being used