GreatSQL社区

搜索

[已解决]

632 16 2023-12-28 17:28
本帖最后由 学无止境 于 2023-12-29 20:05 编辑

全部回复(16)
学无止境 2023-12-28 21:17:05
王权富贵 发表于 2023-12-28 18:10
对比一下执行计划 explain format=tree

我在重新安装和导入数据,明天发你,我晚上测试一下;卸载greatsql,安装mysql8.0.34 ,同一台服务器,使用同样的数据,运行查询的结果在1秒多点;目前在重新安装greatsql和导入数据;
学无止境 2023-12-28 21:34:09
学无止境 发表于 2023-12-28 21:17
我在重新安装和导入数据,明天发你,我晚上测试一下;卸载greatsql,安装mysql8.0.34 ,同一台服务器,使 ...

greatsql执行:
-> Aggregate: count(0)  (cost=2588008.65 rows=1)
    -> Nested loop left join  (cost=2120734.35 rows=4672743)
        -> Index scan on a using index_companyID  (cost=485274.30 rows=4672743)
        -> Filter: (b.Sys_DeptLevel = 2)  (cost=0.25 rows=1)
            -> Single-row index lookup on b using PRIMARY (Sys_DeptID=a.Acc_CompanyID)  (cost=0.25 rows=1)
学无止境 2023-12-28 21:34:41
学无止境 发表于 2023-12-28 21:34
greatsql执行:
-> Aggregate: count(0)  (cost=2588008.65 rows=1)
    -> Nested loop left join  (cos ...

mysql8.034执行:
-> Aggregate: count(0)  (cost=2.39e+6 rows=1)
    -> Nested loop left join  (cost=1.96e+6 rows=4.31e+6)
        -> Index scan on a using index_companyID  (cost=450600 rows=4.31e+6)
        -> Filter: (b.Sys_DeptLevel = 2)  (cost=0.25 rows=1)
            -> Single-row index lookup on b using PRIMARY (Sys_DeptID=a.Acc_CompanyID)  (cost=0.25 rows=1)
学无止境 2023-12-28 21:50:55
KAiTO 发表于 2023-12-28 18:19
可以的话再提供下:
1、show processlist
2、show engine innodb status\G

show processlist:

| Id  | User            | Host                | db                 | Command | Time | State                  | Info                                                                                                 | Time_ms | Rows_sent | Rows_examined |
+-----+-----------------+---------------------+--------------------+---------+------+------------------------+------------------------------------------------------------------------------------------------------+---------+-----------+---------------+
|   8 | event_scheduler | localhost           | NULL               | Daemon  | 2298 | Waiting on empty queue | NULL                                                                                                 | 2297217 |         0 |             0 |
| 292 | root            | 172.16.224.81:64748 | baiduzx_project    | Sleep   |  454 |                        | NULL                                                                                                 |  453909 |        17 |           264 |
| 355 | root            | 172.16.224.81:57173 | information_schema | Sleep   |  354 |                        | NULL                                                                                                 |  353411 |         0 |             0 |
| 383 | root            | localhost           | baiduzx_project    | Query   |    0 | init                   | show processlist                                                                                     |       0 |         0 |             0 |
| 392 | root            | localhost           | baiduzx_project    | Query   |    3 | executing              | SELECT COUNT(*) FROM(select  a.Acc_authorize ,a.Acc_SF_FirstName ,a.Acct_Cust_Name ,a.ID,a.Acc_ISTop |    2638 |         0 |             0 |
+-----+-----------------+---------------------+--------------------+---------+------+----
show engine innodb status\G:
I/O sum[96]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 61
Buffer pool size   81915
Buffer pool size, bytes 1342095360
Free buffers       4000
Database pages     77915
Old database pages 28741
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1210, not young 235385
0.00 youngs/s, 0.00 non-youngs/s
Pages read 300, created 111123, written 162805
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 77915, unzip_LRU len: 0
I/O sum[96]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 62
Buffer pool size   81915
Buffer pool size, bytes 1342095360
Free buffers       4000
Database pages     77915
Old database pages 28741
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 930, not young 171179
0.00 youngs/s, 0.00 non-youngs/s
Pages read 131, created 104693, written 159256
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 77915, unzip_LRU len: 0
I/O sum[96]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 63
Buffer pool size   81915
Buffer pool size, bytes 1342095360
Free buffers       4000
Database pages     77915
Old database pages 28741
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1047, not young 180376
0.00 youngs/s, 0.00 non-youngs/s
Pages read 279, created 110115, written 164332
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 77915, unzip_LRU len: 0
I/O sum[96]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
学无止境 2023-12-29 09:35:20
yejr 发表于 2023-12-29 09:18
1、MySQL和GreatSQL除了PQ外,其他的配置选项都一样吗
2、这条SQL在MySQL和GreatSQL反复多次执行,都是1秒 ...

1、配置基本上一样;
2、反复测试了10几次,都是一样;
3、GreatSQL用的是最新版本8.0.32-25
学无止境 2023-12-29 09:35:50
yejr 发表于 2023-12-29 09:18
1、MySQL和GreatSQL除了PQ外,其他的配置选项都一样吗
2、这条SQL在MySQL和GreatSQL反复多次执行,都是1秒 ...

1、配置基本上一样;
2、反复测试了10几次,都是一样;
3、GreatSQL用的是最新版本8.0.32-25
学无止境 2023-12-29 14:18:31
yejr 发表于 2023-12-29 13:36
方便提供表ddl和测试数据吗,我自己也尝试看看。

抱歉这里面的数据是再用的,不太好发过来,可以远程操作查看;
sql:
EXPLAIN ANALYZE  SELECT COUNT(*) FROM(select  a.Acc_authorize ,a.Acc_SF_FirstName ,a.Acct_Cust_Name ,a.ID,a.Acc_ISTopCustomer,a.Acc_IsVip,a.Acc_AccountName,a.Acc_CustomerName,a.Acc_AccountID,a.Acc_ALevel,a.Acc_BLevel,b.Sys_DeptName,a.Acc_CompanyID  from work_account a left  join sys_dept b on a.Acc_CompanyID=b.Sys_DeptID  and b.Sys_DeptLevel=2 where 1=1   ) as t;

greatsql:
| -> Aggregate: count(0)  (cost=2689843.84 rows=1) (actual time=18842.025..18842.025 rows=1 loops=1)
    -> Nested loop left join  (cost=2208423.44 rows=4814204) (actual time=0.097..18277.875 rows=4914510 loops=1)
        -> Covering index scan on a using index_companyID  (cost=523452.04 rows=4814204) (actual time=0.083..1353.213 rows=4914510 loops=1)
        -> Filter: (b.Sys_DeptLevel = 2)  (cost=0.25 rows=1) (actual time=0.003..0.003 rows=0 loops=4914510)
            -> Single-row index lookup on b using PRIMARY (Sys_DeptID=a.Acc_CompanyID)  (cost=0.25 rows=1) (actual time=0.003..0.003 rows=0 loops=4914510)

Mysql:
| -> Aggregate: count(0)  (cost=2.39e+6 rows=1) (actual time=2287..2287 rows=1 loops=1)
    -> Nested loop left join  (cost=1.96e+6 rows=4.32e+6) (actual time=0.104..2107 rows=4.92e+6 loops=1)
        -> Covering index scan on a using index_companyID  (cost=451138 rows=4.32e+6) (actual time=0.0798..912 rows=4.92e+6 loops=1)
        -> Filter: (b.Sys_DeptLevel = 2)  (cost=0.25 rows=1) (actual time=142e-6..153e-6 rows=0.201 loops=4.92e+6)
            -> Single-row index lookup on b using PRIMARY (Sys_DeptID=a.Acc_CompanyID)  (cost=0.25 rows=1) (actual time=65.8e-6..69.3e-6 rows=0.201 loops=4.92e+6)
学无止境 2024-1-2 09:26:35
yejr 发表于 2023-12-31 09:32
执行计划看起来基本一样,怀疑是系统或硬件层的因素导致的,请检查数据库配置参数,以及CPU、内存、磁盘I ...

硬件应该一致,不存在问题,我把greatsql卸载了,在这台服务器上面部署了mysql8.0.35,同样的数据去执行,只需要1秒多;测试了很多次;都是1秒多;不止跑这条语句,跑其它的语句都比较慢,我这边还有好几条sql,在mysql上面需要135多秒,在greatsql上面需要200多秒;
学无止境 2024-1-2 09:45:14
yejr 发表于 2024-1-2 09:19
咋把标题和内容都清空了?

非常感谢帮忙排查,我这边感觉这个查询差距非常大,进行了多次重新安装或者换服务器,效果还是依旧;可能是我这边部署的原因或者其它原因,部署参考的是文档,估计还有一些细节是我没有注意到的;当前准备先停止greatsql测试;再次感谢
学无止境

1

主题

0

博客

14

贡献

新手上路

Rank: 1

积分
24

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-5-20 00:27 , Processed in 0.021830 second(s), 19 queries , Redis On.
快速回复 返回顶部 返回列表