2012-10-16 7 views
13

Je suis en train d'obtenir une estimation approximative (ordre de grandeur) de combien de temps la requête suivante pourrait prendre:Comment estimer le calendrier de requête SQL?

mysql> EXPLAIN SELECT t1.col1, t1_col4 FROM t1 LEFT JOIN t2 ON t1.col1=t2.col1 WHERE col2=0 AND col3 IS NULL; 
+----+-------------+--------------------+------+---------------+------------+---------+-----------------------------+---------+--------------------------+ 
| id | select_type | table    | type | possible_keys | key  | key_len | ref       | rows | Extra     | 
+----+-------------+--------------------+------+---------------+------------+---------+-----------------------------+---------+--------------------------+ 
| 1 | SIMPLE  | t1     | ref | foobar  | foobar  | 4  | const      | 9715129 |       | 
| 1 | SIMPLE  | t2     | ref | col1   | col1  | 4  | db2.t1.col1     | 42318 | Using where; Using index | 
+----+-------------+--------------------+------+---------------+------------+---------+-----------------------------+---------+--------------------------+ 
2 rows in set (0.00 sec) 

mysql> 
+1

Pourquoi ne pas simplement l'exécuter et l'heure? Je doute que nous puissions donner une estimation précise. –

Répondre

Questions connexes