What tools or ways do mysql and sql server have to check the number of times sql executes?

or answer my question directly: when a sql of select has a primary key and an index, what is the order of its execution? is there a big god to find it first from the primary key or from the index?


Slave primary key or index depends on the query condition, that is, the fields involved after where and order by. You can view it with explain select xxx from your_table .


can be viewed using the trace optimizer, or the visual interface of workbench

-sharp Turn tracing on (it's off by default):
SET optimizer_trace="enabled=on";
SELECT ...; -sharp your query here
SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
-sharp possibly more queries...
-sharp When done with tracing, disable it:
SET optimizer_trace="enabled=off";
Menu