Hello Community!
is there a way to optimize this SQL Query so that it is faster? For Example:
Pseudo:
[...] NOT IN (table1, table2, table3, ...)
The Query in question:
SELECT data FROM _ WHERE p_=:e
AND status <= 1
AND s_ >= :f
AND c_ IS NULL
AND _.id NOT IN (SELECT id FROM c_)
AND _.id NOT IN (SELECT id FROM p_)
AND _.id NOT IN (SELECT id FROM e_)
AND _.id NOT IN (SELECT id FROM f_)
AND _.id NOT IN (SELECT id FROM w_)
AND _.id NOT IN (SELECT id FROM a_)
AND _.id NOT IN (SELECT id FROM k_)
AND _.id NOT IN (SELECT id FROM w_)
AND _.id NOT IN (SELECT id FROM r_) ORDER BY s_ DESC
CodePudding user response:
Not exists may help eg
AND _.id NOT exists (SELECT 1 FROM c_ where c_.id = _.id )