使用DataTable.Select方法查询DataRows的顺序 [英] Order of DataRows queried using the DataTable.Select Method

查看:453
本文介绍了使用DataTable.Select方法查询DataRows的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,


我目前正在使用.NET framework 3.5 API访问SQL Server(2014)数据库中的数据。


了解在 DataTable.Select 方法(下面的链接)的API文档中,有一条注释警告用户指定排序条件参数,以确保查询结果中的正确排序顺序。 / p>

https: //docs.microsoft.com/en-us/dotnet/api/system.data.datatable.select?view=netframework-3.5


1。根据我的观察,当数据库中的数据量很小时,即使未指定sort criteria参数,查询结果也将始终对应于数据库顺序(id)。但是,随着DataTables中DataRows数量的增长,
将达到"突破点"。其中查询结果的顺序开始偏离数据库顺序。我很好奇为什么会出现这种行为?这是否有意优化查询速度?


2。在此"断裂点"之前是否有任何指示或警告标志我可以注意到达了?例如,它是依赖于DataTable中的行数还是整个数据库的文件大小?


请帮忙。


谢谢,

ZY

解决方案

嗨ZY Chua,


谢谢在这里发布。


>> 1. 我是好奇为什么会出现这种行为?这是为了优化查询速度吗?


据我所知,它不会达到"突破点"。你能提供可以重现错误的代码供我测试吗?


如果你想加快速度,你可以用另一种方法。请参考以下链接。


https://stackoverflow.com/questions/3298167/datatable-select-and-performance-issue-in-c-sharp


>> 2。在此"断裂点"之前是否有任何指示或警告标志我可以注意到达了?例如,它是依赖于DataTable中的行数,还是整个数据库的filesize


我无法确定导致"制动点"的原因。微软没有宣布对其进行认证。


最好的问候,


Wendy


Good day,

I am currently using .NET framework 3.5 API to access data in SQL Server (2014) Database.

Understand that in the API documentation for DataTable.Select Method (link below), there is a remark that warns users to specify the sort criteria argument, to ensure the proper sort order in the query results.

https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable.select?view=netframework-3.5

1. From my observation, when the amount of data in the database is small, even when the sort criteria argument is not specified, the query results will always correspond to the database order (id). However, as the amount of DataRows in the DataTables grow, it comes to a "breaking point" where the order of query results starts to deviate from the database order. I am curious about why such a behavior occurs? Is this intended to optimize the query speed?

2. Are there any indicators or warning signs I can look out for before this "breaking point" is reached? For example, is it dependent on the number of rows in a DataTable, or the filesize of the entire Database?

Please help.

Thanks,
ZY

解决方案

Hi ZY Chua,

Thank you for posting here.

>>1.I am curious about why such a behavior occurs? Is this intended to optimize the query speed?

As I know, it would not come to a "breaking point". Could you provide the code which could reproduce the error for me to test?

If you want to speed up, you could use another way. Please refer to the link below.

https://stackoverflow.com/questions/3298167/datatable-select-and-performance-issue-in-c-sharp

>>2. Are there any indicators or warning signs I can look out for before this "breaking point" is reached? For example, is it dependent on the number of rows in a DataTable, or the filesize of the entire Database?

I could not make sure what cause the "braking point". There is no announcement of Microsoft to certify it.

Best Regards,

Wendy


这篇关于使用DataTable.Select方法查询DataRows的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆