I use a view based on a complex query with 17 joins (both inner and left/right outer) and subqueries. All view rows are shown in about 5 seconds.
SELECT * FROM a_view;
One of the view columns has type BIT. And when I filter view rows comparing it with 1, a query works again about 5 seconds.
SELECT * FROM a_view WHERE c = 1;
But when I compare this BIT column with 0, a query works about 50 seconds (10 times slower).
SELECT * FROM a_view WHERE c = 0;
This query which returns the same result rows works as expected about 10 seconds:
SELECT * FROM a_view
EXCEPT
SELECT * FROM a_view WHERE c = 1;
So I wonder why comparing with 0 or 'FALSE' takes so much time? Any ideas, please.
Sorting on this BIT field is fast. Filtering by other columns is fast too.