我有一张(目前)超过 200.000 行的表格。每一行都是我网站上的一个页面,我使用友好的 URL,例如 site.com/itemName。
在我的 SlowQueries 日志中,我有该查询,重复了 1500 多次,加载时间为 1.5 秒。
这是查询:
SELECT * FROM table WHERE `name` LIKE 'S' ORDER BY id DESC LIMIT 1
表类型是 MyISAM。该字段是 varchar 250,上面有 FULLTEXT 索引。另外,我得到了这个 MySQLTuner 结果:
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.61-log
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 191M (Tables: 4)
[--] Data in InnoDB tables: 48K (Tables: 1)
[!!] Total fragmented tables: 1
-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 4h 56m 2s (3M q [34.272 qps], 37K conn, TX: 36B, RX: 3B)
[--] Reads / Writes: 91% / 9%
[--] Total buffers: 290.0M global + 2.7M per thread (151 max threads)
[OK] Maximum possible memory usage: 705.2M (68% of installed RAM)
[OK] Slow queries: 0% (2K/3M)
[OK] Highest usage of available connections: 8% (13/151)
[OK] Key buffer size / total MyISAM indexes: 8.0M/63.3M
[OK] Key buffer hit rate: 100.0% (581M cached / 182K reads)
[!!] Query cache efficiency: 4.7% (146K cached / 3M selects)
[OK] Query cache prunes per day: 0
[!!] Sorts requiring temporary tables: 32% (8K temp sorts / 26K sorts)
[OK] Temporary tables created on disk: 5% (3 on disk / 53 total)
[OK] Thread cache hit rate: 99% (13 created / 37K connections)
[OK] Table cache hit rate: 53% (33 open / 62 opened)
[OK] Open file limit used: 5% (59/1K)
[OK] Table locks acquired immediately: 99% (3M immediate / 3M locks)
[OK] InnoDB data size / buffer pool: 48.0K/8.0M