溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL中SQL_NO_CACHE怎么用

發(fā)布時間:2021-10-29 17:48:50 來源:億速云 閱讀:1249 作者:小新 欄目:MySQL數(shù)據(jù)庫

這篇文章主要介紹了MySQL中SQL_NO_CACHE怎么用,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

SQL_CACHE意思是說,查詢的時候使用緩存。


SQL_NO_CACHE解釋如下:

1.對當前query不使用數(shù)據(jù)庫已有緩存來查詢,則當前query花費時間會多點


2.對當前query的產(chǎn)生的結果集不緩存至系統(tǒng)query cache里,則下次相同query花費時間會多點

當我們想用SQL_NO_CACHE來禁止結果緩存時發(fā)現(xiàn)結果和我們的預期不一樣,查詢執(zhí)行的結果仍然是緩存后的結果。其實,SQL_NO_CACHE的真正作用是禁止緩存查詢結果,但并不意味著cache不作為結果返回給query。

SQL_NO_CACHE的官方解釋如下:

SQL_NO_CACHE means that the query result is not cached. It does not mean that the cache is not used to answer the query.

You may use RESET QUERY CACHE to remove all queries from the cache and then your next query should be slow again. Same effect if you change the table, because this makes all cached queries invalid.


以下是實驗過程:


mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql>  select count(*) from fp_data;
+----------+
| count(*) |
+----------+
|   158404 |
+----------+
1 row in set (0.05 sec)




mysql> select count(*) from fp_data;
+----------+
| count(*) |
+----------+
|   158404 |
+----------+
1 row in set (0.03 sec)




mysql> select SQL_CACHE count(*) from fp_data;
+----------+
| count(*) |
+----------+
|   158411 |
+----------+
1 row in set (0.03 sec)




mysql> select SQL_NO_CACHE count(*) from fp_data;
+----------+
| count(*) |
+----------+
|   158404 |
+----------+
1 row in set (0.02 sec)

感謝你能夠認真閱讀完這篇文章,希望小編分享的“MySQL中SQL_NO_CACHE怎么用”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業(yè)資訊頻道,更多相關知識等著你來學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI