Re: Query Plan

From: Richard Huxton <dev(at)archonet(dot)com>
To: Theo Galanakis <Theo(dot)Galanakis(at)lonelyplanet(dot)com(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query Plan
Date: 2004-09-09 08:28:07
Message-ID: 41401417.6010400@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Theo Galanakis wrote:
>
> Have a question regarding when a Query Plan uses an Index.
>
> I have a basic statement
>
> This query uses the Index Scan:
> explain analyse select * from tablea where columna_id < 57
>
> This query uses Seq Scan:
> explain analyse select * from tablea where columna_id < 58
>
> There are about 5000 records in this table, and columna_id is the primary
> key, which is Indexed... And recently recreated.

OK - what does explain analyse say?

Each line will have two parts, the expected costs/number of rows and the
actual time/number of rows.

If PG is expecting say 50 rows in the first query but 150 in the second
then it might decide a sequential scan is quicker.

Post the outputs of explain analyse and we can compare them.
--
Richard Huxton
Archonet Ltd

In response to

  • Query Plan at 2004-09-09 05:30:48 from Theo Galanakis

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Eckermann 2004-09-09 14:02:06 Re: Isnumeric function?
Previous Message Theo Galanakis 2004-09-09 07:32:06