我已将一个表(InnoDB)从我的数据库复制到另一个数据库,其中包括所有内容和索引。这两个数据库都经过了优化,因此不存在碎片问题。所有都位于同一VPS上。
我注意到这两者之间的性能差异(10-20%),我想解决这个问题。
database1.table(使用索引条件;使用where)
EXPLAIN SELECT price_range FROM database1.table WHERE category = 'seating' AND visibility = 'show' GROUP BY price_range ORDER BY price_range ASC
[id] => 1 [select_type] => SIMPLE [table] => items [type] => ref [possible_keys] => visibility_producer,price_range_visibility,category_visibility,visibility_category_price_range [key] => visibility_category_price_range [key_len] => 228 [ref] => const,const [rows] => 10106 [Extra] => Using index condition; Using where
database2.table(使用where;使用索引)
EXPLAIN SELECT price_range FROM database2.table WHERE category = 'seating' AND visibility = 'show' GROUP BY price_range ORDER BY price_range ASC
[id] => 1 [select_type] => SIMPLE [table] => items [type] => ref [possible_keys] => visibility_producer,price_range_visibility,category_visibility,visibility_category_price_range [key] => visibility_category_price_range [key_len] => 228 [ref] => const,const [rows] => 10106 [Extra] => Using where; Using index
我认为性能的差异是因为数据库1。表正在使用索引条件,而数据库为2。表正在使用索引。相同的查询、相同的索引、相同的服务器。
这怎么可能?关于去哪里找有什么建议吗?