Latest Tech News

Stay updated with the latest in technology, AI, cybersecurity, and more

Filtered by: user_id Clear Filter

A SQL Heuristic: ORs Are Expensive

A SQL Heuristic: ORs Are Expensive Query planning is hard. Sometimes. Queries often have more than one filter (using an and clause). But the developer can often end up in situations requiring an or clause: select count(*) from application where submitter_id = :user_id or reviewer_id = :user_id; But this is slow! With 1,000,000 applications and 1000 users uniformly distributed on both columns, it takes over 100ms.1 If we rewrite it with only and s select ( select count(*) from application

A SQL Heuristic: Ors Are Expensive

A SQL Heuristic: ORs Are Expensive Query planning is hard. Sometimes. Queries often have more than one filter (using an and clause). But the developer can often end up in situations requiring an or clause: select count(*) from application where submitter_id = :user_id or reviewer_id = :user_id; But this is slow! With 1,000,000 applications and 1000 users uniformly distributed on both columns, it takes over 100ms.1 If we rewrite it with only and s select ( select count(*) from application