0

我正在开发需要从 mysql 表中大量读取的 ac# 应用程序。查询如下所示:

SELECT ID3 FROM A INNER JOIN B
USING (ID1)
INNER JOIN C
USING (ID2)
INNER JOIN D
USING (ID3)
WHERE ID3 > @Start AND ID3 <= @End
GROUP BY ID3
HAVING SOME CONDITION

由于表很大,我尝试创建 20 个线程,每个线程执行一个替换的查询

WHERE ID3 > @Start AND ID3 <= @End

WHERE ID3 % 20 = i AND ID3 > @Start AND ID3 <= @End.

但是,运行这个多线程应用程序不会使程序变得更快。我做了一些分析,发现这些线程大部分时间都是空闲的,所以我猜想在 mysql 表上施加了某种锁,这会阻止多个线程访问它们。

我还尝试了“脏读”,它用以下语句将我的查询括起来:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
...
COMMIT;

但是,它似乎并没有带来任何加速。

有人可以帮忙吗?

4

1 回答 1

0

To gain performance, You need to do more than creating additional threads.

  1. Check your MySQL is configured to take advantage of multi core processors. MySQL 5.5 and above can be configured to make use of multiple cores

  2. Consider Partitioning your tables across multiple physical disks.

  3. Make available more RAM to your database. For example, if using innodb, increase innodb_buffer_pool_size to as much as you can afford to. Here is a writeup on that

and this list is not complete.

于 2013-10-18T14:41:46.883 回答