【问题标题】:How can i tune this mysql query to run successfully我怎样才能调整这个 mysql 查询以成功运行
【发布时间】:2023-01-03 01:13:00
【问题描述】:

这是我对 mysql 版本 8 的查询

select sender, fullName, phoneNumber, addressState, businessName, bvn, max(date)
from tranlog t INNER JOIN agent a on t.sender = a.realId 
where captureDate < '2022-03-01' and active = 'Y' and thirdparty = 0 
group by sender


CREATE TABLE `agent` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `realId` varchar(19) DEFAULT NULL,
  `active` char(1) DEFAULT NULL,
  `phoneNumber` varchar(15) DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `addressState` varchar(50) DEFAULT NULL,
  `addressCity` varchar(50) DEFAULT NULL,
  `fullName` varchar(255) DEFAULT NULL,
  `businessName` varchar(255) DEFAULT NULL,
  `corporate` bit(1) DEFAULT b'0',
  `thirdparty` bit(1) NOT NULL DEFAULT b'0',
  PRIMARY KEY (`id`),
  KEY `id` (`fee_group`),
  KEY `realId` (`realId`),
  KEY `agent_password` (`password`),
  KEY `agent_idx` (`active`,`thirdparty`),

) ENGINE=InnoDB AUTO_INCREMENT=29784 DEFAULT CHARSET=latin1;



Table;"Create Table"                
tranlog;"CREATE TABLE `tranlog` (               
  `id` bigint NOT NULL AUTO_INCREMENT                       
  `date` datetime DEFAULT NULL                          
  `captureDate` date DEFAULT NULL                               
  `sender` varchar(50) DEFAULT NULL                         
  PRIMARY KEY (`id`)                
  KEY `tranlog_date` (`date`)                               
  KEY `sender` (`sender`)                           
  KEY `tranlog_capturedate_idx` (`captureDate`)                             
) ENGINE=InnoDB AUTO_INCREMENT=49373312 DEFAULT CHARSET=latin1" 

enter image description here

但我一直收到 'C:windows\TEMP#sql1234_2' is full 我认为这是关于临时表的

我已经将 tmp_table_size 和 max_heap_size 的大小增加到 3G 但没有缓刑,错误不断弹出。 关于如何调整查询的任何想法

【问题讨论】:

    标签: mysql query-optimization


    【解决方案1】:

    在您的查询中添加“限制条款”。看起来你有一个非常大的结果集。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      • 2021-08-01
      • 1970-01-01
      • 2015-03-16
      • 1970-01-01
      • 1970-01-01
      • 2021-07-31
      相关资源
      最近更新 更多