SqlDataReader.GetValue 查询依赖吗?

发布于 2024-09-24 01:29:18 字数 460 浏览 0 评论 0原文

在我的代码中,我有一个像这样的查询

SELECT id,name
FROM people

,我使用 sqldatareader 检索数据。

如果我更改查询,

SELECT id,name
FROM people
WHERE NOT EXISTS(
SELECT *
FROM people_died
WHERE people_died.id = people.id
)

我可以使用 dotTrace 看到第二个查询对 getvalue 的调用需要更长的时间,所以我想知道为什么......

如果您绝对确定这不是好的原因,您能告诉我吗什么可能影响 SqlDataReader.getValue 的性能?

谢谢

编辑:它是否可能取决于表“people”中不在查询中的列? (例如,该表中有很多 ntext 列)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑忘罢 2024-10-01 01:29:18

您的查询返回很多行吗?

SqlDataReader 传输数据。 GetValue 调用可能正在等待更多行流入,而在第二种情况下,由于查询更复杂,这需要更长的时间。

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.

不疑不惑不回忆 2024-10-01 01:29:18

你能尝试一下

SELECT p.id,name
FROM people p left join people_died d
on p.id = d.id
WHERE d.id is null

可能会提高你的表现吗

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

谜兔 2024-10-01 01:29:18

我的问题有一个答案:是的,

在我原来的查询中,我有一个非常非常大的 IN 子句(大约 1400 id),我删除了这个子句,并且对 getValue 的调用现在有正常的执行时间,所以我必须找到一个工作-

无论如何谢谢

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文