title: sqlite painfully slow querying even with index
body: <p>I have a very trivial database with a single table:</p>
  
  <pre><code>CREATE TABLE records ( 
      id INTEGER PRIMARY KEY AUTOINCREMENT, 
      symbol VARCHAR(20) NOT NULL, 
  
      time_ts INTEGER NOT NULL, 
      open_ts INTEGER NOT NULL, 
      close_ts INTEGER NOT NULL, 
  
      open_price REAL NOT NULL,
      high_price REAL NOT NULL,
      low_price REAL NOT NULL,
      close_price REAL NOT NULL,
  
      trades_count INTEGER NOT NULL,
  
      volume_amount REAL NOT NULL,
      quote_asset_volume REAL NOT NULL,
      taker_buy_base_asset_volume REAL NOT NULL,
      taker_buy_quote_asset_volume REAL NOT NULL)
  </code></pre>
  
  <p>and an index:</p>
  
  <pre><code>CREATE INDEX symbol_index ON records (symbol)
  </code></pre>
  
  <p>A size of a database is <code>12.63GB</code>.</p>
  
  <p>I am running this query:</p>
  
  <pre><code>SELECT 
      symbol, 
      MAX(close_ts) max_close_ts, 
      MIN(close_ts) min_close_ts 
  FROM records 
  GROUP BY symbol
  </code></pre>
  
  <p>And it takes about a <strong>minute</strong> to execute it.</p>
  
  <p>As you see, an index is created on <code>symbol</code> column.. However, even with this - the querying is painfully slow..</p>
  
  <p>Even a query like:</p>
  
  <pre><code>select count(id) from records;
  </code></pre>
  
  <p>Takes about 77 seconds to execute. Total number of rows in table is <code>115_944_904</code>.</p>
  
  <p>I expect the record count to be increased twice in the future. Is there anything I can do to make queries work faster? Even with indexes on primary key and on a symbol column I am getting quite bad performance..</p>
  
  <p>Have I hit a limit of any kind?</p>