Untitled

Anonymous
sql
05/22/2024 8:46 AM
576 B
29
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