From: Anibal David Acosta <aa@devshock.com>
To: pgsql-performance@postgresql.org
Subject: postgres not use index, IN statement
Date: Mon, 23 May 2011 17:30:34 -0400
Message-ID: <006801cc1990$a8b34e10$fa19ea30$@devshock.com> (raw)
I have a strange situation.
I have a table of detail with millones of rows and a table of items with
thousands of rows
When I do..
select count(*) from wiz_application_response where application_item_id in
(select id from wiz_application_item where application_id=110)
This query NOT use the index on column application_item_id, instead is doing
a sequential scan
BUT, when I add the range of min and max id of the subquery, the postgres
uses the INDEX
This is the second query...
select count(*) from wiz_application_response where application_item_id
between 908 and 1030 and application_item_id in(select id from
wiz_application_item where application_id=110)
908 and 1030 are limits (lower and upper) of the subquery, the subquery
returns 100 elements aprox.
So, this is some bug?
Thanks!
Anibal
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-performance@postgresql.org
Cc: aa@devshock.com
Subject: Re: postgres not use index, IN statement
In-Reply-To: <006801cc1990$a8b34e10$fa19ea30$@devshock.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