From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kate Collins <klcollins@wsicorp.com>
Cc: postgresql news group <pgsql-sql@postgresql.org>
Subject: Re: SQL command speed
Date: Thu, 18 May 2000 17:47:56 -0400
Message-ID: <25357.958686476@sss.pgh.pa.us> (raw)
In-Reply-To: <3924405E.15014E6B@wsicorp.com>
References: <3924405E.15014E6B@wsicorp.com>
Kate Collins <klcollins@wsicorp.com> writes:
> I did some experimentation, and if the WHERE clause had one or two items
> it would use the index; more and it would not.
Kate, it is reasonable behavior for the planner to stop using
indexscans when there are enough OR clauses. Each OR clause requires
a separate indexscan and so eventually it'll be cheaper to just do one
sequential scan over the whole table. What we appear to have here is
a case of misestimation of the relative costs of index and sequential
scans, leading the planner to switch too soon. Next question is why
the misestimation. It's difficult to say anything without seeing
your EXPLAIN results for different numbers of OR clauses. Also, how
big is the table (how many rows) and how many rows do you actually
get from the query?
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, klcollins@wsicorp.com
Subject: Re: SQL command speed
In-Reply-To: <25357.958686476@sss.pgh.pa.us>
References: <3924405E.15014E6B@wsicorp.com> <25357.958686476@sss.pgh.pa.us>
* 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