无法查看 Pimcore 中文件夹下的所有对象。发生通讯故障

问题描述 投票:0回答:1

在 pimcore 中有 1000 万个对象。当我单击文件夹以在网格视图中显示时,它显示错误:

Timestamp: Fri Nov 08 2024 10:02:01 GMT+0530 (India Standard Time)
Status: 0 | communication failure
URL: /admin/object/grid-proxy?classId=1&folderId=41419&xaction=read&_dc=1731040291645
Method: POST
Message:
undefined
  1. 我已将 Innodb 缓冲池大小增加到 46G
  2. 增加全局等待超时、读取时间等...
  3. 启用慢查询日志技术,当我单击文件夹检索信息时,它显示:
Time: 2024-11-08T04:46:48.085146Z
User@Host: hostname Id: 162
Query_time: 42.447281 Lock_time: 0.000001 Rows_sent: 25 Rows_examined: 35485195
SET timestamp=1731041165;
SELECT object_2.o_id as o_id, object_2.o_type as o_type FROM object_2 WHERE (o_path = '/Assets/folder' OR o_path LIKE '/Assets/folder/%') AND object_2.o_type IN ('object','folder') ORDER BY o_id ASC LIMIT 25;
Time: 2024-11-08T04:47:34.063308Z
User@Host: hostname Id: 162
Query_time: 45.821325 Lock_time: 0.000002 Rows_sent: 1 Rows_examined: 35489690
SET timestamp=1731041208;
SELECT COUNT(*) FROM object_2 WHERE (o_path = '/Assets/folder' OR o_path LIKE '/Assets/folder/%') AND object_2.o_type IN ('object','folder');

我已经在对象上的 o_type、o_path、o_classId 上建立了索引。

这是我的.cnf 文件:

[mysqld]
bind-address = 0.0.0.0
log-bin=mysql-bin
server-id=1
max_execution_time = 99999999
innodb_buffer_pool_size = 46G
innodb_log_file_size = 1G
innodb_file_per_table = 1
key_buffer_size = 2G
sort_buffer_size = 64M
sort_buffer_size = 64M
tmp_table_size = 64M # Set to 64 MB
max_heap_table_size = 64M # Set to 64 MB
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 1
innodb_flush_method = O_DSYNC
innodb_log_buffer_size = 512M
EXPLAIN SELECT COUNT(*) FROM object_2 WHERE (o_path = '/Assets/folder' OR o_path LIKE '/Assets/folder/%') AND object_2.o_type IN ('object','folder');

enter image description here

mysql> SHOW CREATE TABLE objects;

enter image description here

mysql query-optimization pimcore data-objects master-data-management
1个回答
0
投票
  • 这样能得到正确答案吗?

      WHERE  o_path LIKE '/Assets/folder%'
        AND  object_2.o_type IN ('object','folder');
    
  • 添加

    INDEX(o_path, o_type)
    (如果您还没有)。

注意:

OR
尤其不可优化。 我上面所做的是避免
OR
,同时获得[也许]相同的结果。

由于

IN
的作用类似于
OR
,因此第一个查询会更快:

( SELECT  object_2.o_id as o_id, object_2.o_type as o_type
    FROM  object_2
    WHERE  o_path = '/Assets/folder%'
      AND  object_2.o_type = 'object'
    ORDER BY  o_id ASC
    LIMIT  25
) UNION ALL
( SELECT  object_2.o_id as o_id, object_2.o_type as o_type
    FROM  object_2
    WHERE  o_path = '/Assets/folder%'
      AND  object_2.o_type = 'folder'
    ORDER BY  o_id ASC
    LIMIT  25
)
ORDER BY o_id ASC
LIMIT 25;

这与新索引一起减少了必须检查的行数。 如果您需要“接下来的”25 行,请参阅此内容,这有点棘手:Index Cookbook

© www.soinside.com 2019 - 2024. All rights reserved.