SQLite Forum

get only first record found
Login
In a simple test I loaded a million rows into a table into an unindexed column:

create table one_million (counter text);
insert into one_million
WITH RECURSIVE counter(value) AS (
   SELECT 1
     UNION ALL
   SELECT value + 1 FROM counter LIMIT 1000000
) select * from counter;

Then with .timer on I executed these selects:

select * from one_million where counter=1 limit 1;
Run Time: real 0.000 user 0.000000 sys 0.000000

select * from one_million where counter=999999 limit 1;
Run Time: real 0.108 user 0.109375 sys 0.000000

This suggests that the select is indeed stopping after finding the first matching row. Zero time to select the first row, 0.1 secs to get to the last row