views:

41

answers:

3

Hi All,

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 not 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)

+1  A: 

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.

LukeH
There is 1400 rows, and for each row I call getvalue 10 time. I don't understand : the query is executed once, it's not supposed to execute the query when it's getting the data.
remi bourgarel
A: 

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

Beth
It's not about the query itself : if I compare the execution time of ExecuteReader I got nearly the same results (I tried . There is something about sqldatareader that is not explicit.
remi bourgarel
A: 

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

remi bourgarel