Untitled

mail@pastecode.io avatar
unknown
sql
21 days ago
431 B
1
Indexable
Never
-- Slow Query, Because we're applying OR clauses on different indexes
SELECT e.Id
FROM employees e
WHERE e.Foo = 'X' OR F(e.Baz);


-- 2 Queries that we run in Parallel to speed up the response time on backend side.
SELECT e.Id
FROM employees e
WHERE e.Foo = 'X';

SELECT e.Id
FROM employees e
WHERE F(e.Baz);

-- Actual Solution
(SELECT e.Id
FROM employees e
WHERE e.Foo = 'X')
UNION
(SELECT e.Id
FROM employees e
WHERE F(e.Baz));
Leave a Comment