這篇文章主要介紹“提升性能的方法有哪些”,在日常操作中,相信很多人在提升MySQL性能的方法有哪些問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對大家解答”提升MySQL性能的方法有哪些”的疑惑有所幫助!接下來(lái),請跟著(zhù)小編一起來(lái)學(xué)習吧!
提升MySQL性能的幾個(gè)簡(jiǎn)易方法,主要用于設計、開(kāi)發(fā)階段的借鑒。[]1、Carefully choose attribute types and lengths.
仔細選擇字段的類(lèi)型與長(cháng)度。
2、Use fixed-length attributes: try to avoid the types VARCHAR, BLOB, and TEXT.
使用固定長(cháng)度的字段,盡量避免使用VARCHAR、BLOB、TEXT。
3、MySQL can't join tables using an index if the attributes are different types or (in some cases) have different lengths.
如果表的類(lèi)型或長(cháng)度不一致,MySQL在表連接時(shí)將無(wú)法使用索引。
4、Create a statistics table if aggregate functions such as COUNT( ) or SUM( ) are frequently used in queries that contain WHERE clauses and are on large tables.
對于包含where子句的查詢(xún)和大的表,如果經(jīng)常需要用到統計函數(如count、sum),最好創(chuàng )建對應的統計表。
5、If you're inserting large numbers of rows, list the values in one (or few) insert statements as this is much faster to process.
插入大量記錄的時(shí)候,僅在一個(gè)(或少數幾個(gè))insert語(yǔ)句中列出行的值,處理起來(lái)會(huì )快很多。(一個(gè)語(yǔ)句,多個(gè)行,行間用逗號分隔)
6、If large numbers of rows are deleted from a table, or a table containing variable-length attributes is frequently modified, disk space may be wasted.
一個(gè)表刪除大量記錄,或一個(gè)包含變長(cháng)字段的表頻繁修改,磁盤(pán)空間將被浪費。數據沒(méi)有被實(shí)際刪除或修改,僅僅對其位置標注不再使用而已。浪費的磁盤(pán)空間將影響訪(fǎng)問(wèn)速度。一般需要周期性地對表進(jìn)行重組優(yōu)化OPTIMIZE TABLE。
7、MySQL uses statistics about a table to make decisions about how to optimize each query. You can update these statistics by running:
ANALYZE TABLE customer;
MySQL使用一個(gè)表的統計數據來(lái)決定如何優(yōu)化每個(gè)查詢(xún)。更新表統計數據的命令:ANALYZE TABLE ...
8、Use the Heap table type discussed in "Table Types" for small tables that are searched only for exact matches using = or <=>.
使用HEAP類(lèi)型的表。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站