在其他数据库中解释 SELECT

发布于 2024-08-03 15:20:22 字数 295 浏览 8 评论 0原文

我发现EXPLAIN SELECT查询在MySQL中非常有用,因为它提供了有关如何执行SQL的信息,并提供了分析的机会,例如,您应该添加缺失的索引,以便在执行查询之前提高响应本身并分析统计数据。

我的问题是:在 MS Sql、Firebird、Ingres 等数据库中,是否有类似的命令可用?

在 Firebird 中,我们有 PLAN,但它非常弱,因为很多时候必须运行很长的查询才能按顺序运行查看一个简单的错误。

谨致问候,

毛罗·H·莱吉里

I found EXPLAIN SELECT query very useful in MySQL because it gives information on how SQL will be executed and gives the opportunity to analyze, for e.g., missing indexes you should add in order to improve response BEFORE doing the query itself and analyzing stats.

My question is: In databases like MS Sql, Firebird, Ingres, is there a similar command available?

In Firebird we have PLAN, but is very weak because many times one has to run very long queries in order to view a simple mistake.

Best regards,

Mauro H. Leggieri

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

审判长 2024-08-10 15:20:22

Oracle 中:

EXPLAIN PLAN FOR SELECT …

PostgreSQL 中:

EXPLAIN SELECT …

SQL Server 中:

SET SHOWPLAN_XML ON

GO

SELECT …

GO

In Oracle:

EXPLAIN PLAN FOR SELECT …

In PostgreSQL:

EXPLAIN SELECT …

In SQL Server:

SET SHOWPLAN_XML ON

GO

SELECT …

GO
梦过后 2024-08-10 15:20:22

对于 mssql 服务器,您可以使用

SET SHOWPLAN_TEXT ON and SET SHOWPLAN_TEXT OFF

这将阻止查询实际执行,但它将返回查询计划。

对于oracle,你可以使用

SET AUTOTRACE ON or EXPLAIN PLAN

(我不知道firebird或ingres)

For mssql server you can use

SET SHOWPLAN_TEXT ON and SET SHOWPLAN_TEXT OFF

this will prevent queries from actually being exectued but it will return they query plan.

For oracle you can use

SET AUTOTRACE ON or EXPLAIN PLAN

(I don't know about firebird or ingres)

牵你的手,一向走下去 2024-08-10 15:20:22

Oracle中,我们有

EXPLAIN PLAN for sql

http://www.adp-gmbh .ch/ora/explainplan.html

MS SQL Server 中,您可以获得文本或 XML 版本的执行计划。

SET SHOWPLAN_XML ON|OFF
SET SHOWPLAN_TEXT ON|OFF

然而,最好使用 Sql Server Management Studio/TOAD 中的可视化工具查看这些内容。

http://msdn.microsoft.com/en-us/library/ms176058。 aspx

其他非常方便的东西是

SET STATISTICS IO ON|OFF

In Oracle we have

EXPLAIN PLAN for sql

http://www.adp-gmbh.ch/ora/explainplan.html

In MS SQL Server you can get an text or XML version of the execution plan.

SET SHOWPLAN_XML ON|OFF
SET SHOWPLAN_TEXT ON|OFF

However these are best viewed using the visual tool in Sql Server Management Studio/TOAD.

http://msdn.microsoft.com/en-us/library/ms176058.aspx

Something else that is quite handy is

SET STATISTICS IO ON|OFF
ぃ弥猫深巷。 2024-08-10 15:20:22

对于 Ingres,以下内容将为您提供最终选择的计划,以及对行数、磁盘 IO 和 CPU 周期的估计:

set qep

要获取计划但不执行 SELECT,还需要添加

set optimizeonly

重新启用查询执行:

set nooptimizeonly

以获取实际统计信息对于执行的查询,与“set qep”的输出进行比较:

set trace point qe90

请参阅 http://docs.ingres.com/Ingres/9.2/SQL%20Reference%20Guide/set.htm 了解有关上述内容的更多信息。

For Ingres, the following will give you the final plan chosen with estimates as to the number of rows, disk IOs and CPU cycles:

set qep

To get the plan but not execute the SELECT also add

set optimizeonly

re-enable query execution:

set nooptimizeonly

to get the the actual statistics for the executed query, to compare with the output from "set qep":

set trace point qe90

See http://docs.ingres.com/Ingres/9.2/SQL%20Reference%20Guide/set.htm for more information on the above.

雨巷深深 2024-08-10 15:20:22

MS SQL 在 Management Studio 中有一个实用程序,称为在执行查询时显示执行计划(估计的和精确的)。它还可以显示查询的统计信息(运行时间、行数、流量等)

MS SQL has a utility in Management Studio called Display Execution Plan (Estimated and Exact) when executing a query. it can also display statistics for the query (run time, number of rows, traffic etc )

如日中天 2024-08-10 15:20:22

对于 Ingres,另请参阅以下资源:

阅读和解释 a 的示例查询执行计划 (QEP) [pdf]

一个简短的案例研究,演示 QEP 的分析和解释

使用 JDBC 获取 Ingres Qep LockTrace

查询执行计划(QEP)

For Ingres, see also these resources:

Example of Reading and Interpreting a Query Execution Plan (QEP) [pdf]

A brief case study that demonstrates analysis and interpretation of a QEP

Getting Ingres Qep LockTrace Using JDBC

The Query Execution Plan (QEP)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文