gpt4 book ai didi

mysql在不同的服务器上解释不同的结果,相同的查询,相同的数据库

转载 作者:可可西里 更新时间:2023-11-01 06:40:23 25 4
gpt4 key购买 nike

经过大量工作,我终于得到了一个相当复杂的查询,可以非常顺利地工作并非常快速地返回结果。

它在开发和测试中都运行良好,但现在测试速度明显变慢。explain 查询在开发中花费 0.06 秒,在测试中花费了 0.06 秒,现在在测试中花费了 7 秒。

解释略有不同,我不确定为什么会这样来自开发者的解释

-+---------+------------------------------+------+---------------------------------+| id | select_type | table      | type   | possible_keys           | key | key_len | ref                          | rows | Extra   |+----+-------------+------------+--------+-------------------------+-------------+---------+------------------------------+------+---------------------------------+|  1 | PRIMARY     |  | ALL    | NULL                    | NULL | NULL    | NULL                         |    5 |   ||  1 | PRIMARY     | tickets    | ref    | biddate_idx             | biddate_idx | 7       | showsdate.bid,showsdate.date |   78 |   ||  2 | DERIVED     | shows      | ALL    | biddate_idx,latlong_idx | NULL | NULL    | NULL                         | 3089 | Using temporary; Using filesort ||  2 | DERIVED     | genres     | ref    | bandid_idx              | bandid_idx | 4       | activehw.shows.bid           |    2 | Using index   ||  2 | DERIVED     | artists    | eq_ref | bid_idx                 | bid_idx | 4       | activehw.genres.bid          |    1 | Using where   |+----+-------------+------------+--------+-------------------------+------------

在测试中

| id | select_type | table      | type   | possible_keys           | key         | key_len | ref                          | rows   | Extra                                        |+----+-------------+------------+--------+-------------------------+-------------+---------+------------------------------+--------+----------------------------------------------+|  1 | PRIMARY     |  | ALL    | NULL                    | NULL        |    NULL | NULL                         |      5 |                                              ||  1 | PRIMARY     | tickets    | ref    | biddate_idx             | biddate_idx |       7 | showsdate.bid,showsdate.date |     78 |                                              ||  2 | DERIVED     | genres     | index  | bandid_idx              | bandid_idx  |     139 | NULL                         | 531281 | Using index; Using temporary; Using filesort ||  2 | DERIVED     | artists    | eq_ref | bid_idx                 | bid_idx     |       4 | activeHW.genres.bid          |      1 |                                              ||  2 | DERIVED     | shows      | eq_ref | biddate_idx,latlong_idx | biddate_idx |       7 | activeHW.artists.bid         |      1 | Using where                                  |+----+-------------+------------+--------+-------------------------+-------------+---------+------------------------------+--------+----------------------------------------------+5 rows in set (6.99 sec)

尽管查询完全相同,但表的顺序不同。这是导致经济放缓的原因吗?如果是这样,我将如何解决它?dev是windows,testing是centOs。两者都运行相同版本的 mysql 5.0,正如我所说,测试运行完美,我没有对数据库进行任何结构更改。

我运行了 mysqlcheck,所有表都恢复正常。

最佳答案

MySQL 查看表中的数据以及查询本身来决定使用哪个执行计划。

如果两个数据库中的数据相同,我建议对查询中的所有表使用 ANALYZE 或 OPTIMIZE。

关于mysql在不同的服务器上解释不同的结果,相同的查询,相同的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/591210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com