title: simple select query very slow
body: <p>I have a sqlite database that I use as a cache and using this function</p>
  
  <pre><code>def read_cache(table):
      if not table.isidentifier(): # &lt;- my version of sqli protection used to allow for user to provide table and column names
          raise ValueError(f"Invalid table name '{table}'")
      for record in cur.execute(f"SELECT * FROM {table};"):
          yield {**record}
  </code></pre>
  
  <p>a call <code>list(read_cache('some_values'))</code> takes forever (nearly a minute) to return, yet when I run the query against the db itself (as in <code>cur.execute('select * from some_values;').fetchall()</code> or <code>[r for r in cur.execute('select * from some_values;')]</code>) it returns immediately.</p>
  
  <p>The table in question has 40k rows, 2 columns each</p>
  
  <p>What can I do to find the issue or speed it up?</p>
  
  <p><strong>EDIT:</strong> I think I found the issue, the speed issue only occurs in an interpreter that has some <code>threading.Thread</code> running... wonder if the issue is GIL related... will have to see what to do about it...</p>