Re: [SQL] performance inconsistency

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Phuong Ma <pma(at)commandprompt(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] performance inconsistency
Date: 2001-04-04 22:47:01
Message-ID: 12879.986424421@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Phuong Ma <pma(at)commandprompt(dot)com> writes:
> WHERE substr("ORDER_NUM", 1, 1) != 'W'; # (Orders NOT prefixed with W.)

> OR...

> WHERE substr("ORDER_NUM", 1, 1) = 'I'; # (Orders prefixed with I.)

> However, the first query runs in about 10-15 seconds, and the second
> query
> ran for over 40 minutes before I cancelled it.

What query plans does EXPLAIN show for each case? (And have you done
VACUUM ANALYZE lately?)

The change in the WHERE clause may be altering the planner's selectivity
guesstimates enough to cause choice of a less appropriate plan. Hard to
tell without seeing what EXPLAIN has to say, though.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Jorgensen 2001-04-04 22:54:38 Re: Windows install
Previous Message Tom Lane 2001-04-04 22:44:03 Re: Postgres 7.1RC1 on Solaris 7

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-04-04 23:06:03 Re: [7.0.3] optimizing a LIKE query ...
Previous Message Edipo Elder Fernandes de Melo 2001-04-04 22:15:44 Re: Memory and performance