最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MySQL中用通用查詢?nèi)罩菊页霾樵兇螖?shù)最多的語句的教程

 更新時間:2015年12月23日 17:57:54   作者:鮑遠(yuǎn)森  
這篇文章主要介紹了MySQL中用通用查詢?nèi)罩菊页霾樵兇螖?shù)最多的語句的教程,文中附帶了通用查詢?nèi)罩镜拈_啟和清除技巧,需要的朋友可以參考下

MySQL開啟通用查詢?nèi)罩緂eneral log
mysql打開general log之后,所有的查詢語句都可以在general log文件中以可讀的方式得到,但是這樣general log文件會非常大,所以默認(rèn)都是關(guān)閉的。有的時候?yàn)榱瞬殄e等原因,還是需要暫時打開general log的(本次測試只修改在內(nèi)存中的參數(shù)值,不設(shè)置參數(shù)文件)。

general_log支持動態(tài)修改:

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.16  |
+-----------+
1 row in set (0.00 sec)
mysql> set global general_log=1;
Query OK, 0 rows affected (0.03 sec)

general_log支持輸出到table:

mysql> set global log_output='TABLE';
Query OK, 0 rows affected (0.00 sec)
mysql> select * from mysql.general_log\G;
*************************** 1. row ***************************
 event_time: 2014-08-14 10:53:18
  user_host: root[root] @ localhost []
  thread_id: 3
  server_id: 0
command_type: Query
  argument: select * from mysql.general_log
*************************** 2. row ***************************
 event_time: 2014-08-14 10:54:25
  user_host: root[root] @ localhost []
  thread_id: 3
  server_id: 0
command_type: Query
  argument: select * from mysql.general_log
2 rows in set (0.00 sec)
ERROR: 
No query specified

輸出到file:

mysql> set global log_output='FILE';
Query OK, 0 rows affected (0.00 sec)
mysql> set global general_log_file='/tmp/general.log'; 
Query OK, 0 rows affected (0.01 sec)
[root@mysql-db101 tmp]# more /tmp/general.log 
/home/mysql/mysql/bin/mysqld, Version: 5.6.16 (Source distribution). started with:
Tcp port: 3306 Unix socket: /home/mysql/logs/mysql.sock
Time         Id Command  Argument
140814 10:56:44   3 Query   select * from mysql.general_log

查詢次數(shù)最多的SQL語句

analysis-general-log.py general.log | sort | uniq -c | sort -nr
1032 SELECT * FROM wp_comments WHERE ( comment_approved = 'x' OR comment_approved = 'x' ) AND comment_post_ID = x ORDER BY comment_date_gmt DESC
653 SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id in (x) ORDER BY meta_id ASC
527 SELECT FOUND_ROWS()
438 SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'x' AND t.term_id = x limit
341 SELECT option_value FROM wp_options WHERE option_name = 'x' limit
329 SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy in (x) AND tr.object_id in (x) ORDER BY t.name ASC
311 SELECT wp_posts.* FROM wp_posts WHERE 1= x AND wp_posts.ID in (x) AND wp_posts.post_type = 'x' AND ((wp_posts.post_status = 'x')) ORDER BY wp_posts.post_date DESC
219 SELECT wp_posts.* FROM wp_posts WHERE ID in (x)
218 SELECT tr.object_id FROM wp_term_relationships AS tr INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy in (x) AND tt.term_id in (x) ORDER BY tr.object_id ASC
217 SELECT wp_posts.* FROM wp_posts WHERE 1= x AND wp_posts.ID in (x) AND wp_posts.post_type = 'x' AND ((wp_posts.post_status = 'x')) ORDER BY wp_posts.menu_order ASC
202 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1= x AND wp_posts.post_type = 'x' AND (wp_posts.post_status = 'x') ORDER BY wp_posts.post_date DESC limit
118 SET NAMES utf8
115 SET SESSION sql_mode= 'x'
115 SELECT @@SESSION.sql_mode
112 SELECT option_name, option_value FROM wp_options WHERE autoload = 'x'
111 SELECT user_id, meta_key, meta_value FROM wp_usermeta WHERE user_id in (x) ORDER BY umeta_id ASC
108 SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM wp_posts WHERE post_status = 'x'
108 SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy in (x) AND tt.count > x ORDER BY tt.count DESC limit
107 SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy in (x) AND t.term_id in (x) ORDER BY t.name ASC
107 SELECT * FROM wp_users WHERE ID = 'x'
106 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1= x AND wp_posts.post_type = 'x' AND (wp_posts.post_status = 'x') AND post_date > 'x' ORDER BY wp_posts.post_date DESC limit
106 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1= x AND wp_posts.post_type = 'x' AND (wp_posts.post_status = 'x') AND post_date > 'x' ORDER BY RAND() DESC limit
105 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1= x AND wp_posts.post_type = 'x' AND (wp_posts.post_status = 'x') AND post_date > 'x' ORDER BY wp_posts.comment_count DESC limit

PS:mysql general log日志清除技巧
mysql general log日志不能直接刪除,間接方法

USE mysql;
CREATE TABLE gn2 LIKE general_log;
RENAME TABLE general_log TO oldLogs, gn2 TO general_log;

相關(guān)文章

  • MySql分表、分庫、分片和分區(qū)知識點(diǎn)介紹

    MySql分表、分庫、分片和分區(qū)知識點(diǎn)介紹

    數(shù)據(jù)庫的數(shù)據(jù)量達(dá)到一定程度之后,為避免帶來系統(tǒng)性能上的瓶頸。需要進(jìn)行數(shù)據(jù)的處理,采用的手段是分區(qū)、分片、分庫、分表,這里就為大家介紹一下,需要的朋友可以參考下
    2020-02-02
  • Mysql關(guān)于進(jìn)程中的死鎖和解除鎖問題

    Mysql關(guān)于進(jìn)程中的死鎖和解除鎖問題

    Mysql 經(jīng)常會遇到語句或者存儲過程長時間沒有反應(yīng),大概率就是掛掉了,或者死鎖了,這篇文章主要介紹了Mysql關(guān)于進(jìn)程中的死鎖和解除鎖問題,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-07-07
  • MySQL過濾重復(fù)數(shù)據(jù)的兩種方法示例

    MySQL過濾重復(fù)數(shù)據(jù)的兩種方法示例

    數(shù)據(jù)庫生成環(huán)境中經(jīng)常會遇到表中有重復(fù)的數(shù)據(jù),或者進(jìn)行關(guān)聯(lián)過程中產(chǎn)生重復(fù)數(shù)據(jù),下面這篇文章主要給大家介紹了關(guān)于MySQL過濾重復(fù)數(shù)據(jù)的兩種方法,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-04-04
  • Sysbench多線程性能測試工具

    Sysbench多線程性能測試工具

    sysbench是一個多線程性能測試工具,可以進(jìn)行CPU/內(nèi)存/IO/數(shù)據(jù)庫等性能測試,不過我絕大多數(shù)的時候都是用它來對數(shù)據(jù)庫(MySQL)進(jìn)行oltp測試
    2012-11-11
  • cmd連接mysql的方法詳解

    cmd連接mysql的方法詳解

    本篇文章是對cmd連接mysql的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • 史上最全的MySQL備份方法

    史上最全的MySQL備份方法

    史上最全的MySQL備份方法,需要的朋友可以參考下。
    2010-03-03
  • linux CentOS 7.4下 mysql5.7.20 密碼改回來的處理方法

    linux CentOS 7.4下 mysql5.7.20 密碼改回來的處理方法

    這篇文章主要介紹了linux CentOS 7.4下 mysql5.7.20 密碼改回來的處理方法,需要的朋友可以參考下
    2018-11-11
  • 如何解決docker無法啟動的問題

    如何解決docker無法啟動的問題

    這篇文章主要介紹了如何解決docker無法啟動的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • MSSQL根據(jù)ID進(jìn)行分頁實(shí)現(xiàn)方法

    MSSQL根據(jù)ID進(jìn)行分頁實(shí)現(xiàn)方法

    本文將詳細(xì)介紹MSSQL根據(jù)ID進(jìn)行分頁實(shí)現(xiàn)方法,需要的朋友可以參考下
    2012-11-11
  • MySQL日期函數(shù)與日期轉(zhuǎn)換格式化函數(shù)大全

    MySQL日期函數(shù)與日期轉(zhuǎn)換格式化函數(shù)大全

    Mysql作為一款開元的免費(fèi)關(guān)系型數(shù)據(jù)庫,用戶基礎(chǔ)非常龐大,本文列出了MYSQL常用日期函數(shù)與日期轉(zhuǎn)換格式化函數(shù)
    2018-03-03

最新評論

潜江市| 志丹县| 郸城县| 广平县| 赤城县| 昌邑市| 广东省| 萨迦县| 江油市| 长乐市| 临猗县| 射洪县| 东辽县| 岳普湖县| 社会| 冀州市| 石柱| 贵南县| 尼玛县| 郯城县| 江城| 武穴市| 宜川县| 星子县| 武鸣县| 马边| 嫩江县| 通城县| 和硕县| 图们市| 永顺县| 玛纳斯县| 广昌县| 巴塘县| 南华县| 马边| 平乡县| 长治市| 客服| 哈密市| 若羌县|