Causality
Causality

Reputation: 1123

Any command in mysql equivalent to Oracle's autotrace for performance turning

In oracle sql plus, while doing performance testing, I would do

set autotrace traceonly:

which would display the query plan and statistics without printing the actual results. Is there anything equivalent in mysql?

Upvotes: 2

Views: 1763

Answers (2)

spencer7593
spencer7593

Reputation: 108370

No, there's no equivalent available in MySQL, at least not in the community edition.

MySQL does not implement the kind of "instrumentation" that Oracle has in its code; so there's no equivalent to an event 10046 trace.

You can preface your SELECT statement with the EXPLAIN keyword, and that will produce output with information about the execution plan that MySQL would use to run the statement, but that's just an estimate, and not a monitoring of the actual execution.

You can also enable the slow query log on the server, to capture SQL statements that take longer than long_query_time seconds to execute, but that really only identifies the long running queries. That would give you the SQL text, along with elapsed time and a count of rows examined.

Upvotes: 3

G-Nugget
G-Nugget

Reputation: 8836

To get the query plan, just add EXPLAIN to the beginning of a SELECT query.

EXPLAIN SELECT * FROM table

It also estimates the number of rows to be read if that's what statistics you're talking about.

Upvotes: -1

Related Questions