IS NULL vs IS NOT NULL

From: "Vig, Sandor (G/FI-2)" <Sandor(dot)Vig(at)audi(dot)hu>
To: pgsql-performance(at)postgresql(dot)org
Subject: IS NULL vs IS NOT NULL
Date: 2005-02-25 10:10:35
Message-ID: 977921B17B2F2048AA5AAE9B4CBB713E01423D42@huaudigs0035.audi.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

Another "funny" thing: I have a query which runs
on (Linux) PostgreSQL 7.4.x under 10 sec. I tried
to run it on (Windows) PostgreSQL 8.0 yesterday.
It didn't finished at all! (I shoot it down after 10 minutes)
I made various tests and I figured out something interesting:
The same query with:
A, "history.undo_action_id > 0" runs in 10 sec.
B, "history.undo_action_id is not null" runs in 10 sec.
C, "history.undo_action_id is null" runs forever (?!)
I used EXPLAIN but I couldn't figure out what the problem was.
In every explain output are 3 lines:
" -> Index Scan using speed_3 on history (.........)"
" Index Cond: (type_id = 6)"
" Filter: (undo_action_id IS NOT NULL)"
where "speed_3" is a btree index on history.type_id. There is also an index
for history.undo_action_id (btree) but it is not used.

The tables are well indexed, and have about 200.000 records.

The SQL file and the 3 scenarios are in attachment.

Help, anyone?

Vig Sándor

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.

Attachment Content-Type Size
_is_null.txt text/plain 1.2 KB
_is_not_null.txt text/plain 1.3 KB
_greater_than_null.txt text/plain 1.3 KB
query.sql application/octet-stream 555 bytes

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Vig, Sandor (G/FI-2) 2005-02-25 11:19:19 Re: Peformance Tuning Opterons/ Hard Disk Layout
Previous Message SpaceBallOne 2005-02-25 07:41:58 gah! sudden slowdown??