mysql - Very slow NOT EXISTS query issue -


Can anyone tell me if there is any obvious issue why the following query is being completed for 1.3 seconds?

  select COUNT (separate jud.rel_id) as count_result as exp.judging from exp_judging on exp_submissions as jud.rel_id = sub sub form> 

There is a way Is that I can speed up this question. Where ou (jud.judge_id! = 781 or jud.judge_id is zero) and jud.pre = 1 and sub.member_group = 5 does not exist (as exp2judging the left From the sub2.entry_id selection, jud2.rel_id includes exp_submissions as sub2 = where sub2.id (jud2.judge_id = 781) and jud2.pre = 1 and sub2.member_group = 5 and jud2.rel_id = jud.rel_id) < / code>

Wrote again to re 1) Select the first, exp_judging.rel_id, where there is no line with Jj_aidi = 781, 2) Then, calculate these rel_id is derived from exp_judging table.

Edit :

  SELECT COUN T (DISTINCT jud0.rel_id) as exp_judging include jud0 inter alia (rel_id, SUM ( The case jud.judge_id as jud.rel_id, and the remaining 781 1 0 end) as exp_judging jud inter-exp_submissions included as sub but sum.jpg_id = sum_judge_id from sub.id where jud.pre = 1 and sub. group by member_group = 5 jud.rel_id) on jud0.rel_id = judge_id_sums.rel_id Where judge_id_sums.sum_judge_id = 0 judge_id_sums;   

To join Inner exp_judging and exp_submissions jud.rel_id only then jud2 Will count. rel_id is present exp_submissions (as sub2.id ). However, if you want to rely on all jud.rel_id (even if it is not present in exp_submissions ] using LEFT JOIN Can be done.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -