Is SqlDataReader.GetValue query dependant?
In my code I have a Query like this
SELECT id,name
FROM people
I retrieve datas using a sqldatareader.
If I change my query for
SELECT id,name
FROM people
WHERE NOT EXISTS(
SELECT *
FROM people_died
WHERE people_died.id = people.id
)
I can see with dotTrace that the calls to getvalue takes longer with the second query, so I'd like to know why ...
If you're absolutely sure that's n开发者_如何学Pythonot the good reason, can you tell me what can possibly affect the performance of SqlDataReader.getValue ?
Thanks
EDIT : Is it possible that it depends on column from table "people" that are not in the query ? (there is a lot of ntext column in this table for instance)
Does your query return many rows?
A SqlDataReader
streams the data. It's possible that the GetValue
call is waiting for more rows to be streamed in, and that's taking longer to happen in the second case due to the more complex query.
Can you try
SELECT p.id,name
FROM people p left join people_died d
on p.id = d.id
WHERE d.id is null
might improve your performance
I have an answer to my question : YES
In my original query I had a very very big IN clause (around 1400 id), I removed this clause and the call to getValue now have a normal execution time, so I have to find a work-around
Thanks anyway
精彩评论