如何减少mysql对大数据库的查询时间慢

时间:2022-10-13 12:07:33

I have almost 5 gb database on my mysql 5.5 myisam. My os architecture is fedora 64 bit. Now I if I do single query from the table which holding large data query is being slow for more than 30 sec. Can any one please tell me how can I reduce the slow query? I have 2 gb memory and 6 gb swap. [updated] slow log out put is here

我的mysql 5.5 myisam上有近5 gb的数据库。我的os架构是fedora 64位。现在,如果我从表中执行单个查询,那么持有大数据查询的速度超过30秒。请问任何人请告诉我如何减少慢查询?我有2 GB内存和6 GB交换。 [更新]慢速退出放在这里

# Query_time: 19.367274  Lock_time: 0.000109 Rows_sent: 54  Rows_examined: 4263723
SET timestamp=1310052008;
SELECT timestamp FROM nse_data WHERE symbol='NIFTY'AND series='IN' AND timestamp BETWEEN '2011-04-07' AND '2011-07-07' ORDER BY timestamp;

Thanks

2 个解决方案

#1


1  

The first thing to try is to add indexes for the columns you regularly search/order on.

首先要尝试为您经常搜索/订购的列添加索引。

#2


2  

Every query is very different, but at first glance it seems that this particular query can run fastest with this index:

每个查询都是非常不同的,但乍一看似乎这个特定的查询可以用这个索引运行得最快:

ALTER TABLE `nse_data` ADD INDEX `index_nse_data` (`timestamp` ASC, `symbol` ASC, `series` ASC);

Of course, it's just a guess, because I don't know anything about your data :)

当然,这只是猜测,因为我对你的数据一无所知:)

#1


1  

The first thing to try is to add indexes for the columns you regularly search/order on.

首先要尝试为您经常搜索/订购的列添加索引。

#2


2  

Every query is very different, but at first glance it seems that this particular query can run fastest with this index:

每个查询都是非常不同的,但乍一看似乎这个特定的查询可以用这个索引运行得最快:

ALTER TABLE `nse_data` ADD INDEX `index_nse_data` (`timestamp` ASC, `symbol` ASC, `series` ASC);

Of course, it's just a guess, because I don't know anything about your data :)

当然,这只是猜测,因为我对你的数据一无所知:)