Orden SQL, para medicion de tiempo de consulta.

Jonathan
28 de Enero del 2006
Me gustaria saber cual es la sentencia, para medir el tiempo de ejecucion de una consulta en MySql, para poder asi optimizar la consulta el maximo para que me proporcione tiempos menores de ejecucion.

nuncataxi
28 de Enero del 2006
Estimado Jonathan.

Te transcribo parte del manual de sql en la parte optimizacion.


mysql> select benchmark(1000000,1+1);
+------------------------+
| benchmark(1000000,1+1) |
+------------------------+
| 0 |
+------------------------+
1 row in set (0.32 sec)
The above shows that MySQL can execute 1,000,000 + expressions in 0.32 seconds on a
PentiumII 400MHz.
All MySQL functions should be very optimised, but there may be some exceptions, and the
benchmark(loop_count,expression) is a great tool to find out if this is a problem with
your query.
5.2.1 EXPLAIN Syntax (Get Information About a SELECT)
EXPLAIN tbl_name
or EXPLAIN SELECT select_options
EXPLAIN tbl_name is a synonym for DESCRIBE tbl_name or SHOW COLUMNS FROM tbl_name.
When you precede a SELECT statement with the keyword EXPLAIN, MySQL explains how it
would process the SELECT, providing information about how tables are joined and in which
order.
With the help of EXPLAIN, you can see when you must add indexes to tables to get a faster
SELECT that uses indexes to find the records. You can also see if the optimiser joins the
tables in an optimal order. To force the optimiser to use a speci c join order for a SELECT
statement, add a STRAIGHT_JOIN clause.

Espero que te sea util.

Sls
Hg.