我想在MySQL中得到一個詳細的查詢計劃,類似於PostgreSQL中的EXPLAIN ANALYSE展示。有沒有相同的東西?什麼是PostgreSQL的EXPLAIN ANALYZE的MySQL相當於
回答
編輯:雖然不是直接等同或詳細的講解分析這裏有一些工具,你可以看看
MySQL提供講解和過程分析()
http://dev.mysql.com/doc/refman/5.0/en/explain.html
http://dev.mysql.com/doc/refman/5.0/en/procedure-analyse.html
我有在MySQL有EXPLAIN EXTENDED
之前沒有使用過PostgreSQL,它給出的信息比EXPLAIN
更多,可能會給你提供你正在尋找的信息。
只是爲了清楚起見,在接受的答案評論(沒有足夠的業力加評論)
過程分析()是用於不同的目的解釋, 分析了指定列的數據集,並建議最好的數據類型, 即當我們有1000行varchar(255)並且想要檢查我們真正需要多少長度時它很有用,fe它可能會告訴VARCHAR(23)就足夠了
這不回答這個問題,應該是一個評論。沒有-1,因爲你是新的 - 要小心一些可能,實際上會。你應該刪除這個答案,並重新添加它作爲對相關答案的評論。 –
EXPLAIN EXTENDED
MariaDB的/ MySQL的提供一些所謂的EXPLAIN EXTENDED
。然而,EXPLAIN ANALYZE
沒有替代品。 EXPLAIN EXTENDED
不提供任何時間信息,並且內部分解不詳細。
Name: 'EXPLAIN'
Description:
Syntax:
EXPLAIN [explain_type] SELECT select_options
explain_type:
EXTENDED
| PARTITIONS
Or:
EXPLAIN tbl_name
The EXPLAIN statement can be used either as a way to obtain information
about how MySQL executes a statement, or as a synonym for DESCRIBE:
o When you precede a SELECT statement with the keyword EXPLAIN, MySQL
displays information from the optimizer about the query execution
plan. That is, MySQL explains how it would process the statement,
including information about how tables are joined and in which order.
EXPLAIN EXTENDED can be used to obtain additional information.
For information about using EXPLAIN and EXPLAIN EXTENDED to obtain
query execution plan information, see
https://mariadb.com/kb/en/explain/.
o EXPLAIN PARTITIONS is useful only when examining queries involving
partitioned tables. For details, see
http://dev.mysql.com/doc/refman/5.5/en/partitioning-info.html.
o EXPLAIN tbl_name is synonymous with DESCRIBE tbl_name or SHOW COLUMNS
FROM tbl_name. For information about DESCRIBE and SHOW COLUMNS, see
[HELP DESCRIBE], and [HELP SHOW COLUMNS].
URL: https://mariadb.com/kb/en/explain/
例如,這一點taken from this example,
EXPLAIN ANALYZE SELECT *
FROM history AS h1
WHERE EXISTS (
SELECT 1
FROM history AS h2
WHERE h1.lead_id = h2.lead_id
GROUP BY lead_id
HAVING count(is_first OR NULL) > 1
);
會產生這樣的事情在PostgreSQL上,
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Seq Scan on history h1 (cost=0.00..82680.50 rows=1100 width=9) (actual time=0.048..0.065 rows=3 loops=1)
Filter: (SubPlan 1)
Rows Removed by Filter: 3
SubPlan 1
-> GroupAggregate (cost=0.00..37.57 rows=1 width=5) (actual time=0.007..0.007 rows=0 loops=6)
Group Key: h2.lead_id
Filter: (count((h2.is_first OR NULL::boolean)) > 1)
Rows Removed by Filter: 0
-> Seq Scan on history h2 (cost=0.00..37.50 rows=11 width=5) (actual time=0.003..0.004 rows=2 loops=6)
Filter: (h1.lead_id = lead_id)
Rows Removed by Filter: 4
Planning time: 0.149 ms
Execution time: 0.123 ms
(13 rows)
雖然這是MySQL的等價的,
+------+--------------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+--------------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | PRIMARY | h1 | ALL | NULL | NULL | NULL | NULL | 6 | 100.00 | Using where |
| 2 | DEPENDENT SUBQUERY | h2 | ALL | NULL | NULL | NULL | NULL | 6 | 100.00 | Using where |
+------+--------------------+-------+------+---------------+------+---------+------+------+----------+-------------+
2 rows in set, 2 warnings (0.00 sec)
- 1. Oracle相當於Postgres EXPLAIN ANALYZE
- 2. 什麼是PostgreSQL相當於mysql_result()
- 3. 什麼是PostgreSQL相當於SQL Server NVARCHAR?
- 4. 什麼是DBMS_OUTPUT的MySQL相當於
- 5. 如何理解EXPLAIN ANALYZE
- 6. postgresql相當於mysql errno
- 7. 有MySQL的相當於PostgreSQL的array_to_string
- 8. 的PostgreSQL相當於MySQL的--force標誌
- 9. PostgreSQL + ANALYZE + pg_statistic表
- 10. PostgreSQL`analyse` vs`analyze`
- 11. 什麼是BindingFlags.Default相當於?
- 12. 什麼是Ruby相當於PHP的的=
- 13. 什麼是varbinary(10)在postgresql中相當於
- 14. MS SQL Server等效於PostgreSQL的EXPLAIN
- 15. dojo相當於$('body')的是什麼?
- 16. 什麼是WPF中的「OnIdle」相當於
- 17. 什麼是Android中的OnInputListener相當於
- 18. 什麼是新的SDK相當於FB.Facebook.get_isInCanvas
- 19. 什麼是相當於on.event.remove的流
- 20. 什麼是jQuery相當於dojo的marginBox()?
- 21. 什麼是此SQL的HQL相當於
- 22. 什麼是iOS中的onDraw相當於
- 23. 什麼是GraphicsMagick相當於ImageMagick的Blend?
- 24. 什麼是.htaccess的nginx相當於
- 25. 相當於System.Windows.Forms.SendKeys的「鼠標」是什麼?
- 26. 什麼是C++相當於Java的StdIn.isEmpty()
- 27. 什麼是CakePHP相當於WordPress的header.php?
- 28. 什麼是相當於Python的foreach php
- 29. 什麼是gdb的 - lgb相當於--args?
- 30. 什麼是Xamarin中的Edittext.Setinputtype相當於
雖然MySQL的解釋將返回一個n執行計劃,它絕不像PostgreSQL的EXPLAIN ** ANALZYE **輸出那麼詳細。我認爲MySQL中沒有任何內容會提供這樣詳細的計劃。 –
我同意馬,沒有真正的等值。我認爲你必須打開某種擴展的統計數據並運行查詢,然後使用解釋和日誌的輸出才能真正得到類似的結果。 –