title: postgresql: out of shared memory?
body: <p>I'm running a bunch of queries using Python and psycopg2. I create one large temporary table w/ about 2 million rows, then I get 1000 rows at a time from it by using <code>cur.fetchmany(1000)</code> and run more extensive queries involving those rows. The extensive queries are self-sufficient, though - once they are done, I don't need their results anymore when I move on to the next 1000.</p>
  
  <p>However, about 1000000 rows in, I got an exception from psycopg2:</p>
  
  <pre><code>psycopg2.OperationalError: out of shared memory
  HINT:  You might need to increase max_locks_per_transaction.
  </code></pre>
  
  <p>Funnily enough, this happened when I was executing a query to drop some temporary tables that the more extensive queries created.</p>
  
  <p>Why might this happen? Is there any way to avoid it? It was annoying that this happened halfway through, meaning I have to run it all again. What might <code>max_locks_per_transaction</code> have to do with anything?</p>
  
  <p>NOTE: I'm not doing any <code>.commit()</code>s, but I'm deleting all the temporary tables I create, and I'm only touching the same 5 tables anyway for each "extensive" transaction, so I don't see how running out of table locks could be the problem...</p>