Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating query execution time

Tags:

database

mysql

I have a a table of questions in my database here are column and data types of questions table

Field           Datatype
QID             BIGINT
UserID          INT(11)
Question        VARCHAR(100)
Description     Text
Date            DateTime
Status          TINYINT

this table is expected to have around 2 Million entries my question is how do i calculate query execution time if i am searching a record based on QID, UserID or Question.

like image 221
bug Avatar asked May 09 '26 04:05

bug


1 Answers

You can use the General Query Log but it has certain disadvantages too so think before running it on some production environment.

You can use it like:

SET profiling = 1;

and then execute your query like

SHOW PROFILES;

EDIT:-

I dont know if that is the best approach to go with but here it goes as it may depend on the CPU and the number of processes running on your system:

declare @start timestamp
declare @stop timestamp

set @start = select NOW();
//Your query
set @stop = select NOW();

Execution time = @stop - @start

like image 96
Rahul Tripathi Avatar answered May 11 '26 18:05

Rahul Tripathi