From: Richard Huxton <dev@archonet.com>
To: Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: Query Plan
Date: Thu, 09 Sep 2004 09:28:07 +0100
Message-ID: <41401417.6010400@archonet.com> (raw)
In-Reply-To: <82E30406384FFB44AFD1012BAB230B55037D0584@shiva.au.lpint.net>
References: <82E30406384FFB44AFD1012BAB230B55037D0584@shiva.au.lpint.net>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, Theo.Galanakis@lonelyplanet.com.au
Subject: Re: Query Plan
In-Reply-To: <41401417.6010400@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox