Untitled

 avatar
unknown
sql
a year ago
431 B
4
Indexable
-- 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));
Editor is loading...
Leave a Comment