我在查询下运行以从现有表中获取重复记录。以下是我正在做的过程
我的查询在当前表中最多可处理100,000条记录,但当前表中的实时系统数据超过10,000,000,因此查询输出超时。
我的查询是
select
tempTbl.id + 1 as SrNo,
`tempTbl`.`phone` as `phone`,
( CASE WHEN count(panelists.id) > 1 THEN
CONCAT( CONCAT('Phone Already Exist with Panelist ID ', panelists.id
,' and Duplidate counts is ',count('panelists.id'))
ELSE
CONCAT('Phone Already Exist with Panelist ID ',' ',panelists.id)
END
) AS reason from `panelists` as `panelists`
inner join `temp` as `tempTbl` on `panelists`.`phone` = `tempTbl`.`phone`
where `panelists`.`panel_id` = ? group by `tempTbl`.`phone`
having tempTbl.phone != ''
如果有任何帮助建议来优化我的查询,我将感激不尽。提前谢谢。
答案 0 :(得分:0)
您是否已检查并尝试更改并增加MySQL配置文件中的默认值(mysqld部分中的选项connect_timeout) -
[mysqld] connect_timeout=100
请查看并比较两个数据库服务器中的Configuration参数。如果查询在一台服务器上成功执行,我们可以检查两者的配置参数。