title: Why python+sqlite3 is extremely slow?
body: <p>I tried to process the same request to the same database using "Python 2.7.4 + sqlite3" and "Firefox SQLite Manager 0.8.0".</p>
  
  <p>On the tiny database (8000 records) both Python and Firefox work fast and give the same result.</p>
  
  <p>On the bigger database (2600000 records):</p>
  
  <ul>
  <li>SQLite Manager processed database in 28seconds (24 records)</li>
  <li>Python program is working already for 20 minutes without any result</li>
  </ul>
  
  <p>What can be wrong with the following program, so python sqlite3 cannot process the query in reasonable time, while the same request can be processed faster?</p>
  
  <pre><code>import sqlite3
  
  _sql1 = """SELECT DISTINCT J2.rule_description,
                  J2.feature_type,
                  J2.action_item_id,
                  J2.rule_items
  FROM journal J1,
       journal J2
  WHERE J1.base = J2.base
      AND J1.action_item_id=J2.action_item_id
      AND J1.type="Action disabled"
      AND J2.type="Action applied"
      AND J1.rule_description="Some test rule"
      AND J1.action_item_id IN (1, 2, 3, 14, 15, 16, 17, 18, 19, 30, 31, 32)
  """
  
  if __name__ == '__main__':
      sqlite_output = r'D:\results.sqlite'
      with sqlite3.connect(sqlite_output) as connection:
          for row in connection.execute(_sql1):
              print row
  </code></pre>
  
  <p><strong>UPDATE:</strong> <a href="http://www.sqlite.org/sqlite.html">Command Line Shell For SQLite</a> also returns the same 24 records</p>
  
  <p><strong>UPDATE2:</strong> sqlite3.sqlite_version is '3.6.21'</p>