Speed difference between != and = operators? - Mailing list pgsql-general

From Paul Caskey
Subject Speed difference between != and = operators?
Date
Msg-id 3985D639.6523CCCD@nmxs.com
Whole thread Raw
Responses Re: Speed difference between != and = operators?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@nmxs.com        Software Engineer
New Mexico Software    5041 Indian School NE    Albuquerque, NM 87110
--

pgsql-general by date:

Previous
From: Joseph Shraibman
Date:
Subject: Re: How I can undelete recodes?
Next
From: "Bryan White"
Date:
Subject: Re: Corrupted Table