可能重复:
Does MySQL view always do full table scan?优化巨大的MySQL视图
运行SELECT * FROM vAtom LIMIT 10
永远不会返回(我放弃它48小时后);
explain select * from vAtom limit 10
:
+----+-------------+---------------+--------+-------------------------------------------+---------------+---------+------------------------------------------------------------------------------------------------+-----------+---------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------------+--------+-------------------------------------------+---------------+---------+------------------------------------------------------------------------------------------------+-----------+---------------------------------+
| 1 | SIMPLE | A | ALL | primary_index,atom_site_i_3,atom_site_i_4 | NULL | NULL | NULL | 571294166 | Using temporary; Using filesort |
| 1 | SIMPLE | S | ref | primary_index | primary_index | 12 | PDB.A.Structure_ID | 1 | Using index |
| 1 | SIMPLE | C | eq_ref | PRIMARY,chain_i_1,sid_type,detailed_type | PRIMARY | 24 | PDB.A.Structure_ID,PDB.A.auth_asym_id | 1 | Using where |
| 1 | SIMPLE | AT | eq_ref | primary_index | primary_index | 24 | PDB.A.Structure_ID,PDB.A.type_symbol | 1 | Using index |
| 1 | SIMPLE | entityResidue | ref | PRIMARY | PRIMARY | 52 | PDB.S.Structure_ID,PDB.A.label_entity_id,PDB.A.label_seq_id,PDB.A.label_comp_id,PDB.C.Chain_ID | 1 | Using where; Using index |
| 1 | SIMPLE | E | ref | primary_index | primary_index | 12 | PDB.AT.Structure_ID | 1 | Using where |
+----+-------------+---------------+--------+-------------------------------------------+---------------+---------+------------------------------------------------------------------------------------------------+-----------+---------------------------------+
6 rows in set (0.00 sec)
你不必告诉我,600M行是很多。我想知道的是为什么当我只需要10行时速度很慢,我能从这里做什么。
我会很高兴发布show create
每请求任何东西(不想让这个帖子7页长)
可能是相关的:http://stackoverflow.com/questions/637328/does-mysql-view-always-do-full-table-scan –
这很有用,虽然我的重点是在'极限'问题 – Mikhail