从MySQL5.6开始,一个新参数innodb_page_size可以设置Innodb数据页为8K,4K,默认为16K。这个参数在一开始初始化时就要加入my.cnf里,如果已经创建了表,再修改,启动MySQL会报错。 参考手册: - 下面我针对16K和8K做了一个压力测试。 硬件:R710,72G内存,6
从MySQL5.6开始,一个新参数innodb_page_size可以设置Innodb数据页为8K,4K,默认为16K。这个参数在一开始初始化时就要加入my.cnf里,如果已经创建了表,再修改,启动MySQL会报错。
参考手册:
-
下面我针对16K和8K做了一个压力测试。
硬件:R710,72G内存,6块300G、15000转做的RAID10,XFS分区。
my.cnf参数:
1.innodb_buffer_pool_size = 48G 2.innodb_buffer_pool_instances = 8 3.innodb_flush_method = O_DIRECT 4.innodb_file_per_table = 15.innodb_read_io_threads = 16 6.innodb_write_io_threads = 16 7.innodb_io_capacity = 2000 8.innodb_log_files_in_group = 3 9.innodb_flush_log_at_trx_commit = 0 10.innodb_log_file_size = 1024M 11.innodb_max_dirty_pages_pct = 90 1.Sysbench参数(读写):
1.sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=100000000 --max-requests=1000000 --num-threads=100 2.--mysql-host=192.168.110.121 --mysql-port=3306 --mysql-user=admin --mysql-password=123456 --mysql-db=test 3.--oltp-table-name=sbtest --mysql-socket=/tmp/mysql.sock run sbtest表1亿条记录,文件大小24G。
下面是16K性能图:
1.innodb_page_size = 16k
下面是8K性能图:
1.innodb_page_size = 8k
1.结论:默认页16K,对CPU压力较小,平均在20% 2.8K页,CPU压力为30%~40%,但select吞吐量要高于16K
--------------------------------------------------------------------------------
2.Sysbench参数(只读):
1.sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=10000000 --max-requests=0 --num-threads=100 2.--oltp-read-only=on --mysql-host=192.168.110.121 --mysql-port=3306 --mysql-user=admin --mysql-password=123456 --mysql-db=test 3. --oltp-table-name=sbtest --mysql-socket=/tmp/mysql.sock run sbtest表1亿条记录,文件大小24G。
下面是16K和8K性能图:

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)長度,始終使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

mysqlStringTypesIncludeVarChar,文本,char,Enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptoPuptOuptoPepePecifiedLimit.2)textisidealforlargetStortStorStoverStoverStorageWithoutAutAdefinedLength.3)charlisfixed-lenftenge,for forConsistentDatalikeCodes.4)

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

toadduserInmysqleffect和securly,跟隨台詞:1)USEtheCreateUserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNecterAryAryaryPrivilegesSustherthing privilegesgeStatement,usifementStatement,adheringtotheprinciplelastprefilegege.3)

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)創建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。 2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。 3)GrantWriteAccessto'

MySQL中的字符串數據類型包括CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT,排序規則(Collations)決定了字符串的比較和排序方式。 1.CHAR適合固定長度字符串,VARCHAR適合可變長度字符串。 2.BINARY和VARBINARY用於二進制數據,BLOB和TEXT用於大對像數據。 3.排序規則如utf8mb4_unicode_ci忽略大小寫,適合用戶名;utf8mb4_bin區分大小寫,適合需要精確比較的字段。

最佳的MySQLVARCHAR列長度選擇應基於數據分析、考慮未來增長、評估性能影響及字符集需求。 1)分析數據以確定典型長度;2)預留未來擴展空間;3)注意大長度對性能的影響;4)考慮字符集對存儲的影響。通過這些步驟,可以優化數據庫的效率和擴展性。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

Dreamweaver Mac版
視覺化網頁開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具