gpt4 book ai didi

mysql - Magento 产品价格重新索引在 DELETE 查询时挂起

转载 作者:太空宇宙 更新时间:2023-11-03 12:06:16 25 4
gpt4 key购买 nike

当我从 SSH 运行时,我的 Magento Enterprise 1.13 安装的价格重新索引不再完成。所有其他指标似乎都很好。我让它运行的最长时间是 4 天。

服务器规范:

  • 6 个核心
  • 15GB 内存
  • 200GB 硬盘
  • 中央操作系统 6

我可以通过使用“SHOW PROCESSLIST;”看到它在这个查询中以“发送数据”状态挂起:

 DELETE `index_price`  FROM `catalog_product_index_price` AS `index_price` LEFT JOIN `catalog_product_index_price_idx` AS `ip_tmp` ON index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id WHERE (ip_tmp.entity_id IS NULL)

我已经检查了两个表的属性(当这个查询运行时):

  • catalog_product_index_price = 16,437,361 行,类型为 INNODB,大小为 2.4GB
  • catalog_product_index_price_idx = 16,314,589 行,类型为 INNODB,大小为 2.1GB

表结构和索引如下:

CREATE TABLE IF NOT EXISTS `catalog_product_index_price` (
`entity_id` int(10) unsigned NOT NULL COMMENT 'Entity ID',
`customer_group_id` smallint(5) unsigned NOT NULL COMMENT 'Customer Group ID',
`website_id` smallint(5) unsigned NOT NULL COMMENT 'Website ID',
`tax_class_id` smallint(5) unsigned DEFAULT '0' COMMENT 'Tax Class ID',
`price` decimal(12,4) DEFAULT NULL COMMENT 'Price',
`final_price` decimal(12,4) DEFAULT NULL COMMENT 'Final Price',
`min_price` decimal(12,4) DEFAULT NULL COMMENT 'Min Price',
`max_price` decimal(12,4) DEFAULT NULL COMMENT 'Max Price',
`tier_price` decimal(12,4) DEFAULT NULL COMMENT 'Tier Price',
`group_price` decimal(12,4) DEFAULT NULL COMMENT 'Group price'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Price Index Table';

ALTER TABLE `catalog_product_index_price`
ADD PRIMARY KEY (`entity_id`,`customer_group_id`,`website_id`), ADD KEY `IDX_CATALOG_PRODUCT_INDEX_PRICE_CUSTOMER_GROUP_ID` (`customer_group_id`), ADD KEY `IDX_CATALOG_PRODUCT_INDEX_PRICE_WEBSITE_ID` (`website_id`), ADD KEY `IDX_CATALOG_PRODUCT_INDEX_PRICE_MIN_PRICE` (`min_price`), ADD KEY `IDX_CAT_PRD_IDX_PRICE_WS_ID_CSTR_GROUP_ID_MIN_PRICE` (`website_id`,`customer_group_id`,`min_price`);

CREATE TABLE IF NOT EXISTS `catalog_product_index_price_idx` (
`entity_id` int(10) unsigned NOT NULL COMMENT 'Entity ID',
`customer_group_id` smallint(5) unsigned NOT NULL COMMENT 'Customer Group ID',
`website_id` smallint(5) unsigned NOT NULL COMMENT 'Website ID',
`tax_class_id` smallint(5) unsigned DEFAULT '0' COMMENT 'Tax Class ID',
`price` decimal(12,4) DEFAULT NULL COMMENT 'Price',
`final_price` decimal(12,4) DEFAULT NULL COMMENT 'Final Price',
`min_price` decimal(12,4) DEFAULT NULL COMMENT 'Min Price',
`max_price` decimal(12,4) DEFAULT NULL COMMENT 'Max Price',
`tier_price` decimal(12,4) DEFAULT NULL COMMENT 'Tier Price',
`group_price` decimal(12,4) DEFAULT NULL COMMENT 'Group price'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Price Indexer Index Table';

ALTER TABLE `catalog_product_index_price_idx`
ADD PRIMARY KEY (`entity_id`,`customer_group_id`,`website_id`), ADD KEY `IDX_CATALOG_PRODUCT_INDEX_PRICE_IDX_CUSTOMER_GROUP_ID` (`customer_group_id`), ADD KEY `IDX_CATALOG_PRODUCT_INDEX_PRICE_IDX_WEBSITE_ID` (`website_id`), ADD KEY `IDX_CATALOG_PRODUCT_INDEX_PRICE_IDX_MIN_PRICE` (`min_price`);

我已经尝试在两个表上运行 mysql 命令“OPTIMIZE”并运行检查任何外键问题都没有帮助。

我也尝试过更改 my.cnf,因为有人建议可能已达到“innodb_lock_wait_timeout”限制。请参阅下面我的 my.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0

thread_concurrency=12
thread_cache_size=64
#wait_timeout=600
#wait_timeout=60
#table_cache=2048
table_cache=1024
query_cache_type=1
query_cache_size=1024M
#query_cache_limit=16M
query_cache_limit=32M
key_buffer_size=256M
max_allowed_packet=2048M
#max_connections=1000
max_connections=600
tmp_table_size=1024M
max_heap_table_size=1024M
table_definition_cache=4000
table_open_cache=4000
#sort_buffer_size=1M
#read_buffer_size=1M
sort_buffer_size=8M
read_buffer_size=4M
join_buffer_size=16M
#below files to help with crons
#open_files_limit=131070
wait_timeout=9000
connect_timeout=9000

innodb_thread_concurrency=12
innodb_file_per_table=1
#innodb_buffer_pool_size=4G
#innodb_buffer_pool_size=3G
innodb_buffer_pool_size=7G
innodb_lock_wait_timeout=9000
innodb_flush_log_at_trx_commit=1
innodb_additional_mem_pool_size=24M
#innodb_fast_shutdown=0
innodb_log_buffer_size=8M
innodb_log_file_size=128M

#log_error=/var/log/mysql/mysql-error.log
#log_queries_not_using_indexes=1
#slow_query_log_file=/var/log/mysql/mysql-slow.log
#log_slow_queries=ON

最佳答案

我通过修改产品重新索引以使用表的完整主键删除“catalog_product_index_price”表中的产品价格条目来修复此问题。为此,您需要覆盖此文件:/app/code/core/Enterprise/Catalog/Model/Index/Action/Product/Price/Abstract.php 并更改

$select = $this->_connection->select()
->from(array('index_price' => $this->_getTable('catalog/product_index_price')), null)
->joinLeft(
array('ip_tmp' => $this->_getIdxTable()),
'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id',
array()
)
->where('ip_tmp.entity_id IS NULL');

为了...

$select = $this->_connection->select()
->from(array('index_price' => $this->_getTable('catalog/product_index_price')), null)
->joinLeft(
array('ip_tmp' => $this->_getIdxTable()),
'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id AND index_price.customer_group_id = ip_tmp.customer_group_id',
array()
)
->where('ip_tmp.entity_id IS NULL');

这样做需要您自担风险,目前看来一切正常。我能看到的唯一缺点是您的“catalog_product_index_price”表中可能会留下一些冗余行。除此之外,我没有遇到任何问题。

关于mysql - Magento 产品价格重新索引在 DELETE 查询时挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26467575/

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