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
Post a Comment