I use raw SQL with parameters in Dapper. Query speed is normal.
Something like this:
string sql = "SELECT * FROM SomeTable WHERE messages IN ('Volvo', 'BMW', 'Ford', 'Mazda')"
var results = conn.Query(sql);
When I change parameters with @messages, the speed is too slow:
string sql = "SELECT * FROM SomeTable WHERE messages IN (@cars)"
string[] cars = { "Volvo", "BMW", "Ford", "Mazda" };
var results = conn.Query(sql, new {cars});
PS: string[] size is almost 300.
messagesis indexed or not.string[] size is almost 300.did you try with a raw string with 300 items? It's not possible to pass an array of values as a parameter, so Dapper will actually generate anINclause with the values. The two queries should be identical.sometableis too small, the server may decide to use a scan instead of a seek, especially since it needs to retrieve all columns. BTW without the table schema and row counts, we're as blind as the server.