Quando si esegue una query, non desidero che stampi sulla console. Voglio solo vedere l'ora.Come verificare quanto tempo impiega la query MySQL?
9166 rows in set (0.90 sec)
Questo è tutto ciò che voglio vedere, invece di stampare tutto.
Quando si esegue una query, non desidero che stampi sulla console. Voglio solo vedere l'ora.Come verificare quanto tempo impiega la query MySQL?
9166 rows in set (0.90 sec)
Questo è tutto ciò che voglio vedere, invece di stampare tutto.
Prova questo semplice esempio
mysql> set profiling=1;
mysql> select count(*) from comment;
mysql> select count(*) from message;
mysql> show profiles;
+----------+------------+------------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------------+
| 1 | 0.00012700 | select count(*) from comment |
| 2 | 0.00014200 | select count(*) from message |
+----------+------------+------------------------------+
2 rows in set (0.00 sec)
è possibile scrivere la query all'interno di sub-query con COUNT
di fare il trucco come:
SELECT COUNT(1)
FROM (SELECT * FROM your_table WHERE ...) a
Si può rallentare la query un po ', come si sta facendo anche COUNT
ma penso che il suo trascurabile.
Per la misurazione delle prestazioni di query che si può accendere PROFILES
in MySQL come:
SET profiling = 1;
Per maggiori dettagli su PROFILES
vedere here.
$starttime = microtime(true);
//Do your query and stuff here
$endtime = microtime(true);
$duration = $endtime - $starttime; //calculates total time taken
Si dice "ERROR 1248 (42000): Ogni tabella derivata deve avere il proprio alias"? – TIMEX
assegnare qualsiasi alias alla tabella derivata come ho dato 'a' alla fine – Omesh