sql server - Table Valued Parameter has slow performance because of table scan -
i have aplication passes parameters procedure in sql. 1 of parameters table valued parameter containing items include in clause.
because table valued parameter has no statistics attached when join tvp table has 2 mil rows slow query.
what alternatives have ?
again, goal pass values procedure included in clause:
select * table1 id in (select id @mytvp)
or
select * table1 t1 join @mytpv tvp on t1.id = tvp.id
although looks need run query once each row in table1, exists optimizes more efficient join or in. so, try this:
select * table1 t exists (select 1 @mytvp p t.id=p.id)
also, sure t.id same datatype p.id , t.id has index.
Comments
Post a Comment