Query time
Moderator: General Moderators
Query time
How do you find out how long it takes for a query to run?
Re: Query time
If you're using MySQL from the command line, it displays the time in seconds at the end of the results. What are you trying to do, optimize a query? If you are, I'd suggest that you check into the available tools for optimizing. There are lots of little 'gotchas' that won't necessarily be obvious just from the raw time it takes to run. For example, are there other concurrent users of the database? I'd have to research it myself, but I'm pretty sure there are built-in environment variables that hold the query time of the most recent query.GeXus wrote:How do you find out how long it takes for a query to run?
Now, in case you're not using MySQL, or even if you are, an option would be to write a test PHP script that saves the timestamp just prior to running the query, then immediately getting another timestamp and subtracting the two.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
If you want to do this with PHP, have a look at the example code on the microtime() manual page.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA