Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining execution time of queries in SQLite

Tags:

I am creating a program for analyzing and generating queries. I was curious if there currently exists a method within SQLite such that I could query the time taken for a query to process? I am unable to modify my install in any way, so this method needs to work out of the box. I am writing my tool in python, and although I guess I could use the timer class to time execution -this method will not work when I am connecting to remote machines (and return a consistent timing.)

like image 889
sampwing Avatar asked Aug 04 '11 20:08

sampwing


People also ask

How long does a SQLite query take?

Query one takes about 30ms, but 150ms to fetch the data from the database. Query two takes about 3ms -this is the one I therefore prefer-, but also takes 170ms to fetch the data.

Does SQLite have a query optimizer?

SQLite provides the ability for advanced programmers to exercise control over the query plan chosen by the optimizer.

How many queries can SQLite handle?

The SQLite website (https://www.sqlite.org/) uses SQLite itself, of course, and as of this writing (2015) it handles about 400K to 500K HTTP requests per day, about 15-20% of which are dynamic pages touching the database. Dynamic content uses about 200 SQL statements per webpage.


1 Answers

From within the sqlite3 command-line program you can do:

.timer ON select * from my_table; 

This will print the CPU time taken for the query.

like image 135
Tim Avatar answered Sep 22 '22 08:09

Tim