Speed difference between != and = operators?

From: Paul Caskey <paul(at)nmxs(dot)com>
To: Postgres Users <pgsql-general(at)postgresql(dot)org>
Subject: Speed difference between != and = operators?
Date: 2000-07-31 19:40:41
Message-ID: 3985D639.6523CCCD@nmxs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This query takes 206 seconds:

SELECT t1.blah, t1.foo, t2.id
FROM t1, t2, t3
WHERE t1.SessionId = 427
AND t1.CatalogId = 22
AND t1.CatalogId = t3.CatalogId
AND t2.id = t3.SomeId
AND t2.Active != 0

If I change the last line to this, it takes 1 second:

AND t2.Active = 1

The "Active" field is 0 or 1. The query returns the same rows, either way
(about 1700 rows). There is an index on the Active field.

These two queries both take 1 second:

SELECT * FROM t2 WHERE Active = 1;
SELECT * FROM t2 WHERE Active != 0;

Any ideas? Possible bug?

--
Paul Caskey paul(at)nmxs(dot)com Software Engineer
New Mexico Software 5041 Indian School NE Albuquerque, NM 87110
--

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-07-31 19:53:01 Re: Corrupted Table
Previous Message Bryan White 2000-07-31 19:38:32 Re: Corrupted Table