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";
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34a0f-2bf20.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34a0f-2bf20.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?