Stopping on first match in sqlite query

I have a sqlite3 database that is 4GB and 400k rows. The id column is a sequential number starting at 1. If I ask for the next

select * from game where id = 1

      

After printing the first match, the query continues until it reaches the 400k line, so it will take a few seconds for the query to complete.

How do I make the request stop at the first match?

Or how to go directly to a specific row since the id and rowcount are the same?

+3


source to share


1 answer


Just add LIMIT 1

to your request:



SELECT * FROM game WHERE id = 1 LIMIT 1;

      

+9


source







All Articles