sp_executesql is slow with parameters
问题 I'm using dapper-dot-net as an ORM and it produces the following, slow-executing (1700ms), SQL code. exec sp_executesql N'SELECT TOP 5 SensorValue FROM "Values" WHERE DeviceId IN (@id1,@id2) AND SensorId = @sensor AND SensorValue != -32768 AND SensorValue != -32767',N'@id1 bigint,@id2 bigint,@sensor int',@id1=139,@id2=726,@sensor=178 When I modify this code by removing the parameters the query executes blazingly fast (20ms). Should the lack of these parameters actually make this big