SQL Server: count request optimization -


i'm looking solution optimize select query i'm running on big tables (more 100m items per table), here current solution i'm using, takes more 40min!!

select count(a.id)    tablea         join tableb b           on a.ref_xid = b.xid              , a.ref_yid = b.yid   ( b.filtre = 1            or b.filtre = 7 )         , not exists (select id                           tablec                          xid = a.xid                                , yid = a.yid);  

for query:

select count(a.id)  tablea join      tableb b       on a.ref_xid = b.xid , a.ref_yid = b.yid  b.filtre in (1, 7) ,        not exists (select 1                      tablec c                    c.xid = a.xid , c.yid = a.yid                  );  

you want indexes on tableb(filtre, xid, yid), tablea(ref_xid, ref_yid), , tablec(xid, yid).


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -