8

I have a sqlite3 database worth 4GB and 400k rows. The id column is a consecutive number starting at 1. If I query the following

select * from game where id = 1

After printing the first match the query continues until it reach the 400k row, thus taking a few seconds to finish the query.

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

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

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
milarepa
  • 759
  • 9
  • 28
  • 1
    possible duplicate of [Using the LIMIT statement in a SQLite query](http://stackoverflow.com/questions/2497677/using-the-limit-statement-in-a-sqlite-query) – Sergey Kalinichenko Jan 03 '15 at 05:49

1 Answers1

17

Just add a LIMIT 1 to your query:

SELECT * FROM game WHERE id = 1 LIMIT 1;
ianaya89
  • 4,153
  • 3
  • 26
  • 34