我正在研究「在線數據流」項目,我需要一些幫助來構建最佳性能的數據庫。目前,我有一個包含玩家,包括文件,海報圖像,POST_ID等構建數據庫以獲得最佳性能
+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| post_id | int(11) | YES | | NULL | |
| file | mediumtext | NO | | NULL | |
| thumbs_img | mediumtext | YES | | NULL | |
| thumbs_size | mediumtext | YES | | NULL | |
| thumbs_points | mediumtext | YES | | NULL | |
| poster_img | mediumtext | YES | | NULL | |
| type | int(11) | NO | | NULL | |
| uuid | varchar(40) | YES | | NULL | |
| season | int(11) | YES | | NULL | |
| episode | int(11) | YES | | NULL | |
| comment | text | YES | | NULL | |
| playlistName | text | YES | | NULL | |
| time | varchar(40) | YES | | NULL | |
| mini_poster | mediumtext | YES | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
一個有100K記錄大約需要0.5秒,查詢和性能的不斷降低,因爲我有更多的記錄所有相關信息的一個表。 ('7000')AND類型='1';其中post_id('7000')AND_type ='1'中的post_id解釋SELECT * FROM dle_playerFiles
+----+-------------+-----------------+------+---------------+------+---------+------+-------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------+------+---------------+------+---------+------+-------+-------------+
| 1 | SIMPLE | dle_playerFiles | ALL | NULL | NULL | NULL | NULL | 61777 | Using where |
+----+-------------+-----------------+------+---------------+------+---------+------+-------+-------------+
我該如何改進DB結構? youtube等大型網站如何構建數據庫?
您創建了哪些索引? – MatBailie
無,從解釋'possible_keys' = null – user2696962
也許創建一些? *(和/或谷歌他們瞭解如何以及爲什麼?)* – MatBailie