MYSQL

HOW TO BENCHMARK MYSQL QUERY TIME

(quick guide & examples)

OPEN COMMAND LINE & RUN MYSQL mysql --user USER --password PASS --database DB

RUN MYSQL IN COMMAND LINE

01

RUN SQL QUERY SELECT INSERT REPLACE UPDATE DELETE

RESULTS WILL SHOW "TIME TAKEN"

MYSQL TOOLS & MANAGERS

02

THESE TOOLS WILL ALSO SHOW THE QUERY EXECTION TIME

ENABLE PROFILING SET profiling = 1;

MYSQL QUERY PROFILING

03

RUN SQL QUERIES SELECT INSERT REPLACE UPDATE DELETE

SHOW PROFILES SHOW PROFILES;

BENCHMARK FUNCTION

04

BENCHMARK(LOOP, STATEMENT) FOR EXAMPLE, RUN 1+1 FOR 1000 TIMES BENCHMARK(1000, 1+1)

$runs = 1000; $start = microtime(true); $stmt = $pdo->prepare(SQL); for ($i=0; $i<$runs; $i++)   { $stmt->execute(); } $end = microtime(true); $taken = $end - $start;

MANUAL TEST SCRIPT (PHP)

05

BENCHMARKING TOOLS

06