当前位置:网站首页>mysql优化,sql执行非常卡顿,不改变sql结构达到10秒内结束
mysql优化,sql执行非常卡顿,不改变sql结构达到10秒内结束
2022-06-23 03:36:00 【CSDN问答】
一个sql执行非常卡顿,不改变sql结构,9万多+8万多数据,达到10秒内结束查询
原sql SELECT * FROM a_itemsListVer WHERE (locate('防水材料,防水卷材', waterproof) > 0 OR itemsListId IN (SELECT itemsListId FROM a_itemsListOtherVer WHERE locate('防水卷材', waterproofMemo) > 0 ))
//样例只保留了部分关键字段。
//表一 9万多条数据
CREATE TABLE a_itemsListVer (id varchar(20) NOT NULL,
itemsListId varchar(20) NOT NULL COMMENT '主项目id',waterproof varchar(150) NOT NULL DEFAULT '',
PRIMARY KEY (id),
KEY fId (itemsListId),
KEY waterproof (waterproof) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
//样例数据 INSERT INTO a_itemsListVer VALUES ('zgypu9zqg5ys', 'vs6h24c5b79w', '防水卷材');
//表二 8万多条数据
CREATE TABLE a_itemsListOtherVer (id varchar(20) NOT NULL COMMENT 'itemsListVerId相同',itemsListId varchar(20) NOT NULL COMMENT '主项目id',waterproofMemo varchar(200) NOT NULL DEFAULT '',
updateTime datetime NOT NULL COMMENT '更新时间',time datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (id),
KEY itemsListId (itemsListId),
KEY waterproofMemo (waterproofMemo) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
//样例数据 INSERT INTO a_itemsListOtherVer VALUES ('zgzrzulitiid', 'vs6h24c5b79w', '防水卷材', '2022-6-16 11:06:41', '2022-6-16 11:06:46');
目前运行结果都是超过几分钟。数据库服务器配置2核4G
改造的最后一版还是很卡
SELECT COUNT(*) FROM a_itemsListVer WHERE ( if(locate('防水材料,防水卷材', waterproof)>0 , true ,
if(
locate ((SELECT GROUP_CONCAT(waterproofMemo) FROM a_itemsListOtherVer WHERE itemsListId=a_itemsListVer.itemsListId ),'防水卷材' )>0
,true,0 ) ) )
我想要达到的结果。能正常运行,10秒内结束查询
边栏推荐
- Analysis of the number of urban residents covered by basic medical insurance, their treatment and medical treatment in other places in China in 2021 [figure]
- Tcapulusdb Jun · industry news collection (III)
- Engineer culture: should the company buy genuine software
- 数据交易怎样实现
- 软件项目管理 8.4.软件项目质量计划
- Postman calls relevant interfaces of CLS API 3.0
- Goframe framework: log configuration management
- Banknext microservice: a case study
- ABCD identifier of SAP mm initial cycle count
- WordPress modifying fixed links and pseudo statics
猜你喜欢

Jmeter- (V) simulated user concurrent login for interface test

Analysis on the development of China's graphene industry chain in 2021: with the support of energy conservation and environmental protection policies, the scale of graphene industry will continue to e
![[Zeng shuge's laser slam notes] gmapping filter based slam](/img/93/b940ad95508d1c0d23642022df37f2.png)
[Zeng shuge's laser slam notes] gmapping filter based slam
![[quick view] Analysis on the development status and future development trend of the global and Chinese diamond cultivation industry in 2021 [figure]](/img/f1/972a760459a6d599b5681aa634df09.jpg)
[quick view] Analysis on the development status and future development trend of the global and Chinese diamond cultivation industry in 2021 [figure]

MySQL common instructions

新版kali切换最高账户

Fetch request details

Analysis on the development of duty-free industry in Hainan Province in 2021: the implementation of the new policy makes the duty-free market in Hainan more "prosperous" [figure]

What if the self incrementing IDs of online MySQL are exhausted?
![[greed] leetcode991 Broken Calculator](/img/6e/ce552b55899c6e8d3c37f524f99f82.png)
[greed] leetcode991 Broken Calculator
随机推荐
JSON. Function of the stringify() optional parameter
Tcapulusdb Jun · industry news collection (V)
Centos7 installing MySQL and configuring InnoDB_ ruby
Apicloud native module, H5 module and multi terminal component tutorial
D overloading nested functions
Analysis on the development of duty-free industry in Hainan Province in 2021: the implementation of the new policy makes the duty-free market in Hainan more "prosperous" [figure]
【LeetCode】23. 合并K个升序链表
数据加密技术之源代码加密
Record an edusrc vulnerability mining
The compatibility of remotefx schemes is related to multiple factors
What is the difference between the poll () method and the remove () method?
What is the potential of dmail based on Web3.0? First round financing of $10 million?
【二分】leetcode1011. Capacity To Ship Packages Within D Days
mysql常用指令
January 17, 2022: word rule II. Give you a pattern and a character
Easysearcher cannot find the IP address of easynvr hardware. How to solve it?
Tencent released the global DDoS threat report in 2021: DDoS threat has become the preferred extortion method for criminal gangs
WordPress modifying fixed links and pseudo statics
Initialize MySQL Gorm through yaml file
The MIUI 13 development version of Xiaomi mobile phone blocks the chrome application and cannot be opened after installation