Re: SQL command speed

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kate Collins <klcollins(at)wsicorp(dot)com>
Cc: postgresql news group <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SQL command speed
Date: 2000-05-18 21:47:56
Message-ID: 25357.958686476@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Kate Collins <klcollins(at)wsicorp(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2000-05-18 22:02:02 Re: SQL command speed
Previous Message Christopher Sawtell 2000-05-18 21:18:56 Re: Re[2]: lower() for varchar data by creating an index