In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
SELECT deptno, empno, ename FROM emp
WHERE empno IN
(SELECT max(empno) FROM emp
WHERE empno < _value_
AND deptno IN (SELECT deptno FROM emp
WHERE empno = _value_)
AND sal >= 5000)
UNION
SELECT deptno, empno, ename FROM emp
WHERE empno = _value_
UNION
SELECT deptno, empno, ename FROM emp
WHERE empno IN
(SELECT MIN(empno) FROM emp
WHERE empno > _value_
AND deptno IN (SELECT deptno FROM emp
WHERE empno = _value_)
AND sal >= 5000)
SELECT deptno, empno, ename FROM emp
WHERE empno IN
(COALESCE((SELECT max(empno) FROM emp
WHERE empno < _value_
AND deptno IN (SELECT deptno FROM emp
WHERE empno = _value_)
AND sal >= 5000),
(SELECT max(empno) FROM emp
WHERE deptno IN (SELECT max(deptno) FROM emp
WHERE deptno < (SELECT deptno FROM emp
WHERE empno = _value_)
AND sal >= 5000))))
UNION
SELECT deptno, empno, ename FROM emp
WHERE empno = _value_
UNION
SELECT deptno, empno, ename FROM emp
WHERE empno IN
(COALESCE((SELECT MIN(empno) FROM emp
WHERE empno > _value_
AND deptno IN (SELECT deptno FROM emp
WHERE empno = _value_)
AND sal >= 5000),
(SELECT min(empno) FROM emp
WHERE deptno IN (SELECT min(deptno) FROM emp
WHERE deptno > (SELECT deptno FROM emp
WHERE empno = _value_)
AND sal >= 5000))))
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.