MySql in子句 效率低下優化(親測有效,從200秒變1秒)
MySql in子句 效率低下優化
背景:
更新一張表中的某些記錄值,更新條件來自另一張含有200多萬記錄的表,效率極其低下,耗時高達幾分鐘。
update clear_res set candelete=0 where resid in ( select distinct resourceid from att_attentionresult where important=0 );
耗時 365s
優化後
update clear_res set candelete=0 where resid in ( select resourceid from ( select distinct resourceid from att_attentionresult where important=0 ) as tmp );
耗時 1.41s
總結:對於where xxx in 子句效率極其低下問題,經過in的子句外包裝一層select xxx from( ... )as tmp 後,極大優化效率。
https://www.cnblogs.com/hdwang/p/4749152.html
相關推薦
MySql in子句 效率低下優化(親測有效,從200秒變1秒)
MySql in子句 效率低下優化 背景: 更新一張表中的某些記錄值,更新條件來自另一張含有200多萬記錄的表,效率極其低下,耗時高達幾分鐘。 update clear_res set candelete=0 where resid in ( select distinct re
MySql in子句 效率低下優化
背景: 更新一張表中的某些記錄值,更新條件來自另一張含有200多萬記錄的表,效率極其低下,耗時高達幾分鐘。 update clear_res set candelete=0 where resid in ( select distinct resourceid fro
NLog 日誌框架搭建講解(親測有效,代碼齊全)
希望 auth ble log4 context tar 網上 targe localhost 前言:最近,搭建代碼框架時,想要找一款日誌框架。因為之前都是使用Log4net,所以這次打算使用一款新的NLog嘗試下,感謝網上的這麽多朋友發布的博文,對我有不少的啟發作用。不過
UE啟用(親測有效,通過註冊機啟用)
之前一直用的是SublimeText系列,也感覺很好用的,在文字編輯上UE 和 SublimeText感覺差不多,用起來都比較舒服,但是我看中的UE一個強大的功能,可以在編輯時切換行模式和列模式。同時操作多列,雖然很少用到,但是真用的時候就方便很多了。另外UE也有一系列的產品,比如UC就
java Timer定時任務。每天的某個時刻開啟(親測有效,直接執行)
這是管理類:import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import ja
Java 加密解密zip檔案(親測有效,附原始碼和jar包)
有一個朋友問我改怎麼做,到網上搜了一下,果然有類似的文章及大神解決了此類難題,現將程式碼及所需的jar包附上,供大家使用 package test1; import java.io.File;
Ubuntu18.04下python3匯入MySQL模組(親測有效)
我是Ubuntu18.04,分別裝好了python3和mysql8.0,現在要在python3中匯入mysql模組。 如果直接使用: sudo apt install python-mysql 命令,預設安裝的是python2的模組,所以我開始百度,但是出來的
MySQL下載安裝詳情教程(親測有效)
1.下載MySQL資料庫可以訪問官方網站:https://www.mysql.com/ 2.點選DOWNLOADS模組下的Community模組下的MySQL Community Server進行下載。 由於目前最新版本是:MySQL Community
完全解除安裝mysql(親測有效!!!)
1.停止mysql服務。 “執行”——>“cmd”——>輸入“net stop mysql;” 看連結: 2.將控制面板中的mysql正常解除安裝 控制面板——》“程式”,找到並解除安裝! 3.找到安裝路徑,將所有
windows安裝mysql-8.0.12-winx64和Navicat客戶端連線(親測有效)
1.首先下載mysql-8.0.12-winx64 : 2.下載完畢進行解: 解壓發現沒有my.ini和data檔案,這些檔案都不需要建立。 3.安裝 快捷鍵:win + R,在執行視窗輸入cmd回車。 切換到資料庫bin目錄 進入f盤f:回車,進入b
Mac忘記MySQL root密碼解決方法(親測有效)
重置MySQL root密碼 重置MySQL root使用者的密碼: 1)新建一個文字檔案sql.txt,寫入修改使用者密碼的SQL語句。 MySQL 5.7.6及更高版本寫這句: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Ubuntu16.04 sogou中文輸入出現亂碼(親測有效)
post lis install nbsp use 無法 list 輸入法 all 1 如果是剛安裝完的搜狗輸入法,則輸入: sudo apt-get install -f,進行依賴性檢查,判斷是否缺依賴項。如果是之前一直可以輸入中文的,突然無法輸入的,則不是依賴項的
[轉]PhpStorm中如何使用Xdebug工具,入門級操作方法(親測有效)
bin 查找 內置函數 php ont 單獨 php程序 conf get 0 前言 網上試過很多方案,有的根本無效,有的是有效一段時間後失效,然而這個方法是一直有效果,所以留底記錄一下 1 簡介 PhpStorm是一個輕量級且便捷的PHP IDE,其提供的智能代碼補全,
親測有效,解決Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) ";
https 轉載 配置 ket 現在 存在 can selector 們的 版權聲明:本文為博主原創文章,未經博主允許不得轉載。 h
webstorm 2018安裝與啟用【mac也適用】(親測有效)
安裝webstorm 2018 只需2步即可,永久免費 (1)下載官方網址http://www.jetbrains.com/webstorm/download/#section=windows:中間有部分圖片沒有截圖預設就行 (2)註冊: ①下載破解壓縮包:連結:https://p
JSONException: syntax error, expect {, actual [, pos 0 異常的解決方法(親測有效)
出現這個問題一般是出現在json格式轉換成java物件的時候,比如我們有這麼一段json資料: [{"accept_address":"廣東省深圳市軟體產業基地","remark":"順豐速運 已收取快件(測試資料)","opcode":50,"accept_time":"2018-05-0
解決cannot resolve symbol “xxxx”的問題(親測有效)
今天做專案的時候匯入了一個api介面,並且把附帶的jar包也拷貝到了Maven專案中,但是有個方法一直報cannot resolve symbol “xxxx”。 百思不得其解,在網上搜了各種各樣的方法也沒有解決,這個問題其實就是無法解析某方法,也可以說是找不到,那麼就是我們的依賴出了問題,
JavaWeb企業級專案中接入順豐官方API實現物流實時查詢(親測有效)
由於現在順豐與快遞100鬧掰了,所以使用快遞一百已經查不到順豐的物流資訊了,包括快遞鳥等,現在想要在專案中實現順豐快遞的物流查詢只能用順豐官方API來查詢,然而這個官方的API並沒有快遞一百那些介面那麼容易,需要很複雜的一套流程,並且順豐用的返回形式都是XML檔案,就需要設計到XML檔案的修改與
無法連線虛擬磁碟服務解決辦法(親測有效)
今天給虛擬機器的win7安裝了office 因為是iso檔案,也不知道為什麼無法讀取,就用了cd/dvd連線光碟的方式安裝了office 但是安裝完之後本機的檔案資源管理器多了一個cd/dvd,強迫症很不能忍 而且點開檔案資源管理器上面的進度條很慢,磁碟載入不出來 一點cd/dv
Quartus II 13.0 下載安裝、破解教程(親測有效)
作者因為安裝過程沒有截圖,所以沒有圖片,但是一定正確,因為裝過不止一次,有問題,可以聯絡作者 一、 首先是Quartus II 13.0.1 軟體的下載 如果你沒有那麼高的要求,用個低版本的Quartus II 就足夠了,而且低版本的軟體比較穩定, 為了免去大家找安裝檔案版本號不匹配的情況,