title: C# Improving SQLite SELECT performance
body: <p>I have a program which has an SQLite database with the table: CREATE TABLE files(path TEXT, last_backup DATETIME)</p>
  
  <p>The total database size is 33Mb with about 250000 records in it.</p>
  
  <p>I am running a block of code which will SELECT any records which have the path field matching a string and return the last_backup DATETIME value. If no records are found a DateTime.MinValue is returned.</p>
  
  <p>When I initially ran my program the database was empty so it will of returned the min date every time. Now there are a lot of records to check the program is running the same process much slower.</p>
  
  <p>My code block for querying the table is:</p>
  
  <pre><code>internal DateTime lastBackupDate(String file)
  {
      DateTime date = DateTime.MinValue;
      string sql = "SELECT * FROM files WHERE path=@param1";
      SQLiteCommand command = new SQLiteCommand(sql, _connection);
      command.Parameters.AddWithValue("@param1", file);
      SQLiteDataReader reader = command.ExecuteReader();
      while (reader.Read())
      {
          date = (DateTime)reader["last_backup"];
      }
      return date;
  }
  </code></pre>
  
  <p>My question is, is there anything that can be done to speed this up?</p>