免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
03.慢查詢
問題是:如何從一個(gè)大項(xiàng)目中,迅速的定位執(zhí)行速度慢的查詢語(yǔ)句?

1.首先我們了解mysql數(shù)據(jù)庫(kù)的一些允許狀況
show session | global  status like ‘uptime’ //運(yùn)行的時(shí)間 session當(dāng)前回話 global所有的
show status like ‘com_select’ //select命名使用的次數(shù),update,delete,等一樣
show status like connections //查詢多少個(gè)鏈接
-----------------------------------
netstats -anb  //   查詢鏈接的詳細(xì)信息 ip,端口等 ;mysql服務(wù)端口為3306 客戶端隨機(jī)分配端口

------------------------------------

2.如何定位慢查詢


步驟:
i:構(gòu)建一個(gè)大表(400萬(wàn)以上數(shù)據(jù))->用存儲(chǔ)過程構(gòu)建,要去數(shù)據(jù)貼近真實(shí)
創(chuàng)建表
 create table dept(/*部門表*/
deptno mediumint unsigned not null default 0,//編號(hào) unsigned 無(wú)符號(hào)整數(shù)
dname varchar(20) not null default "", //名稱
loc varchar(13) not null default "",//地點(diǎn)
)engine=myisam default charset=utf8;
---------------
create table emp(/*員工表*/
empno mediumint unsigned not null default 0,//編號(hào)
ename varchar(20) not null default "",//名字
job varchar(9) not null default "",//工作
mgr mediumint unsigned not null default 0,//上級(jí)編號(hào)
hiredate date not null,//入職時(shí)間
sal decimal(7,2) not null,//薪水
comm decimal(7,2) not null,//紅利
deptno mediumint unsigend not null default 0,//部門編號(hào)
)engine=myisam default charset=utf8;

------------------
create table salgrade(/*工資級(jí)別表*/
grade mediumint unsigend not null default 0,
losal decimal(17,2) not null,
hisal decimal(17,2) not null,
)engine=myisam default charset=utf8;

-----------------
創(chuàng)建函數(shù).php
-----------------------------
舉例:
<?php
$con=mysql_connect("localhost","root","root");
if(!$con){
die(“失敗”
}
mysql_select_db('temp');
$sql="select rand_string(6) from dual";//dual 亞元表
>

---------------------------


ii:show variables like ‘long_query’ //顯示慢查詢的時(shí)間是多少
      set long_query_time=1 //修改慢查詢時(shí)間為1s ;然后打開數(shù)據(jù)庫(kù)運(yùn)行一天,再查看慢查詢
iii:show status like ‘slow_queries’ //顯示慢查詢次數(shù)
iiii:把慢查詢的sql記錄到日志中,默認(rèn)不會(huì)打開。需要在啟動(dòng)mysql時(shí)候,指定慢查詢記錄


本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ecshop訂單表結(jié)構(gòu)ecs_order_info說明
DedeCMS V5.6二次開發(fā)數(shù)據(jù)庫(kù)文檔
mysql壓力測(cè)試腳本實(shí)例
MySQL函數(shù)&存儲(chǔ)過程
? Mysql數(shù)據(jù)庫(kù)的優(yōu)化技術(shù)
ecshop訂單表結(jié)構(gòu)ecs
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服