Khamis Abuelkomboz wrote:
CREATE INDEX idx_t2_t1id ON t2 (t1id, deleted);
Doent not help.
whereas the following quere takes "no" time:
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t1.id=t2.id WHERE t1.deleted<>1
This is fast, because no entries has been found to be joined.
This is not true - "deleted" hast the value 0 in all rows - so
"t1.deleted=0" and "t1.deleted<>1" brings the same result.
And now - check this out - the following query ist fast too:
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t1.id=t2.id WHERE NOT NOT
(t1.deleted=0)
Whereas
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t1.id=t2.id WHERE (t1.deleted=0)
is slow. And as far as I undestand this should be the same, or do I miss
sth?
thx
Michael