mardi 8 septembre 2015

SQLite SELECT with max() performance

I have a table with about 1.5 million rows and three columns. Column 'timestamp' is of type REAL and indexed. I am accessing the SQLite database via PHP PDO.

The following three selects run in less than a millisecond:

select timestamp from trades
select timestamp + 1 from trades
select max(timestamp) from trades

The following select needs almost half a second:

select max(timestamp) + 1 from trades

Why is that?

Aucun commentaire:

Enregistrer un commentaire