gpt4 book ai didi

php - 慢速依赖子查询 - 如何提高性能?

转载 作者:搜寻专家 更新时间:2023-10-30 19:56:14 25 4
gpt4 key购买 nike

我的数据库有表名事务,其中有 20000 条记录。当我运行这个查询时

SELECT T1.* FROM transactions AS T1
WHERE T1.ppno IN
(SELECT T2.PPNO FROM transactions AS T2
WHERE T2.ppno = T1.ppno
HAVING COUNT(T2.ppno) = $doublescount)
ORDER BY T1.ppno,T1.numb

运行至少需要 3 分钟。如何加速这个查询?

编辑

show create table transactions 返回为

CREATE TABLE `transactions` (
`eidx` int(10) unsigned NOT NULL,
`numb` int(10) unsigned NOT NULL,
`date` date NOT NULL,
`time` varchar(45) NOT NULL,
`name` varchar(45) NOT NULL,
`add1` varchar(45) NOT NULL,
`add2` varchar(45) NOT NULL,
`city` varchar(45) NOT NULL,
`phno` varchar(45) NOT NULL,
`nati` varchar(45) NOT NULL,
`ppno` varchar(45) NOT NULL,
`cuam` varchar(45) NOT NULL,
`tcam` varchar(45) NOT NULL,
`valu` varchar(45) NOT NULL,
`srch` varchar(45) NOT NULL,
`stax` varchar(45) NOT NULL,
`taxp` varchar(45) NOT NULL,
`roun` varchar(45) NOT NULL,
`amnt` varchar(45) NOT NULL,
`encd` varchar(45) NOT NULL,
`mocd` varchar(45) NOT NULL,
`endt` varchar(45) NOT NULL,
`modt` varchar(45) NOT NULL,
`sflg` varchar(5) NOT NULL,
`category` varchar(45) NOT NULL DEFAULT 'NA',
`branch` varchar(10) NOT NULL,
PRIMARY KEY (`numb`,`branch`,`date`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED

最佳答案

关于php - 慢速依赖子查询 - 如何提高性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6404140/

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