ADO 搜索性能
因为我对 ADO 的底层并不熟悉,所以我想知道使用 VB6 查找记录的两种方法中哪一种通常会产生更快的结果。
使用“select”语句并使用“where”作为限定符。如果记录集计数为零,则未找到该记录。
选择使用客户端游标迭代记录的所有记录,直到找到记录或根本找不到记录。
记录集在 10,000 条记录范围内,并且会不断增长。另外,除了上面提到的之外,我对任何能缩短搜索时间的事情都持开放态度。
Because I am not familiar with ADO under the hood, I was wonder which of the two methods of finding a record generally yields quicker results using VB6.
Use a 'select' statement using 'where' as a qualifier. If the recordset count yields zero, the record was not found.
Select all records iterating through records with a client-side cursor until record is found, or not at all.
The recordset is in the range of 10,000 records and will grow. Also, I am open to anything that will yield shorter search times other than what was mentioned.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果结果大于0,则在数据库中找到满足条件的记录。你不太可能比这更快。在
WHERE
子句中使用的列上的正确索引可以显着提高性能。If the result is greater than 0 the record satisfying your condition was found in the database. It is unlikely you would get any faster than this. Proper indexes on the columns you are using in the
WHERE
clause could considerably improve performance.在我能想到的每种情况下,使用 where 子句进行选择会更快。
即使在客户端代码将迭代整个数据库(例如 Access 等基于文件的数据库)的情况下,您也将使用用 C 或 C++ 编写的优化代码来执行选择(在数据库驱动程序中)。这总是比VB6。
对于数据库引擎(SQL、MySQL 等),性能提升甚至更为深远。通过使用 where 子句,您可以限制必须通过网络传输的数据量,从而极大地提高响应。
一些额外的性能提示:
最后,VB.NET 的数据库性能令我震惊,它比最快的 VB6 代码快了好几倍。
In every case I can think of, selecting using the where clause is faster.
Even in situations where the client code will iterate through the whole database (file-based databases like Access, for example), you will have optimized code written in c or c++ doing the selection (in the database driver.) This is always faster than VB6.
For Database engines (SQL, MySQL, etc), the performance increase can even be more profound. By using the where clause, you limit the amount of data that must be transmitted over the network, vastly improving the response.
Some additional performance tips:
Lastly, I was shocked by VB.NET's database performance, it being several times faster than the fastest VB6 code.