title: Is it normal that sqlite.fetchall() is so slow?
body: <p>I have an sql query that selects from two inner joined tables. The execution of the select statement takes about 50 seconds. However, the fetchall() takes 788 seconds and it only fetches 981 results. This is the query and fetchall code:</p>
  
  <pre><code>time0 = time.time()
  self.cursor.execute("SELECT spectrum_id, feature_table_id "+
                      "FROM spectrum AS s "+
                      "INNER JOIN feature AS f "+
                      "ON f.msrun_msrun_id = s.msrun_msrun_id "+
                      "INNER JOIN (SELECT feature_feature_table_id, min(rt) AS rtMin, max(rt) AS rtMax, min(mz) AS mzMin, max(mz) as mzMax "+
                                   "FROM convexhull GROUP BY feature_feature_table_id) AS t "+
                      "ON t.feature_feature_table_id = f.feature_table_id "+
                      "WHERE s.msrun_msrun_id = ? "+
                      "AND s.scan_start_time &gt;= t.rtMin "+
                      "AND s.scan_start_time &lt;= t.rtMax "+
                      "AND base_peak_mz &gt;= t.mzMin "+
                      "AND base_peak_mz &lt;= t.mzMax", spectrumFeature_InputValues)
  print 'query took:',time.time()-time0,'seconds'
  
  time0 = time.time()
  spectrumAndFeature_ids = self.cursor.fetchall()      
  print time.time()-time0,'seconds since to fetchall'
  </code></pre>
  
  <p>Is there a reason why the fetchall takes so long?</p>
  
  <hr>
  
  <h2>update</h2>
  
  <p>Doing:</p>
  
  <pre><code>while 1:
      info = self.cursor.fetchone()
      if info:
          &lt;do something&gt;
      else:
          break
  </code></pre>
  
  <p>is going just as slow as</p>
  
  <pre><code>allInfo = self.cursor.fetchall()         
  for info in allInfo:
      &lt;do something&gt;
  </code></pre>