CRITICAL
Rule Definition
Use of 'NOT EXIST' keyword slows down the query
Remediation
Queries should not use 'NOT EXIST' keywords in WHERE clause
Violation Code Sample
SELECT o.id
FROM purchase AS o
WHERE o.date < TODAY - 365
AND NOT EXISTS
(
SELECT g.id
FROM tcggamesummary AS g
WHERE g.id = o.id
);
Fixed Code Sample
Use join with null check:
SELECT o.id
FROM purchase AS o LEFT OUTER
JOIN tcggamesummary AS g
ON g.id = o.id
WHERE o.date < TODAY - 365
AND g.id IS NULL;
Related Technologies
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.