Re: performance inconsistency - Mailing list pgsql-sql

From Tom Lane
Subject Re: performance inconsistency
Date
Msg-id 12879.986424421@sss.pgh.pa.us
Whole thread Raw
In response to performance inconsistency  (Phuong Ma <pma@commandprompt.com>)
List pgsql-sql
Phuong Ma <pma@commandprompt.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

pgsql-sql by date:

Previous
From: Edipo Elder Fernandes de Melo
Date:
Subject: Re: Memory and performance
Next
From: "Josh Berkus"
Date:
Subject: Re: Need to do an ALTER TABLE.