简体   繁体   English

如何加速从Mysql数据库中检索数据

[英]How to speed up data retrieval from Mysql database

I am working with c# windows form application and using mysql as back end. 我正在使用c#windows form应用程序并使用mysql作为后端。 I have a table employee. 我有一名员工。 In that I have more 2000 rows its just a example likely more record. 在那里我有更多的2000行,它只是一个例子可能更多的记录。 When I'm retrieving and filtering the data from database my application is getting slow. 当我从数据库中检索和过滤数据时,我的应用程序变得越来越慢。 Is there another way to retrieve database in good speed? 还有另一种方法可以快速检索数据库吗? Shall I achieve the speed by using Linq? 我应该使用Linq达到速度吗?

Just make sure that you perform filtering in the database using WHERE (if you are using SQL for data access). 只需确保使用WHERE在数据库中执行过滤(如果使用SQL进行数据访问)。

If you are using linq or not does not matter much as long as the SQL that is executed in the database is good (proper filtering using WHERE and indexes). 只要在数据库中执行的SQL是好的(使用WHERE和索引进行适当的过滤),如果您使用linq或不使用linq并不重要。

How do you retrieve data now? 你现在如何检索数据? are you using ado.net? 你在用ado.net吗? but Stored procedures with ado.net is the fastest way I guess, are you sure that data retrieve is the slowest,2000 records is not so big table, so I guess your UI components are working slower? 但是ado.net的存储过程是我猜的最快的方法,你确定数据检索是最慢的,2000条记录不是那么大的表,所以我猜你的UI组件工作得更慢?

2000 records is a relatively small table. 2000年的记录是一个相对较小的表。 What is the size of each row? 每行的大小是多少?

Retrieving / Filtering from such a small table should be very fast atleast at a DB level. 从这样一个小表中检索/过滤应该在数据库级别至少非常快。

  • View the Query Plan of your query and Optimize your query based on it. 查看查询的查询计划并根据它优化查询。

  • Especially check your indexes and see how they are being used in your query and if you need to add / change any for them to be optimally used. 特别是检查您的索引并查看它们在查询中的使用方式,以及是否需要添加/更改它们以便最佳地使用它们。

If you post your query and its execution plan, people might be able to point out some specifics as to how you may be able to improve on it! 如果您发布查询及其执行计划,人们可能会指出一些具体信息,说明您可以如何改进它!

你可以通过使用延迟加载(在互联网上有几个教程)来加快速度,或者只选择那些你感兴趣的教程。

将索引添加到参与JOINSWHERE子句的字段中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM