Re: Iterating through cur and cur.fetchone() - Mailing list psycopg

From Daniele Varrazzo
Subject Re: Iterating through cur and cur.fetchone()
Date
Msg-id CA+mi_8ZA3b3+NbcW6uonovkJuCPn-4Kn1TNLJYEXCZ56yX6U2A@mail.gmail.com
Whole thread Raw
In response to Re: Iterating through cur and cur.fetchone()  (Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>)
List psycopg
2011/10/10 Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>:
> Sorry, I stupid mistake. But I have been using psycopg for a year and
> I have some issue with memory usage on large cursors.
> Any tips on how to reduce the memory usage.

You can use server-side cursors, aka named cursors
<http://initd.org/psycopg/docs/usage.html#server-side-cursors>. In the
latest psycopg versions, iteration on the cursor (i.e. the "for record
in cur: ..." syntax) is more efficient than iterating with fetchone.
Everything is explained in the docs.

-- Daniele

psycopg by date:

Previous
From: Håvard Wahl Kongsgård
Date:
Subject: Re: Iterating through cur and cur.fetchone()
Next
From: thomas veymont
Date:
Subject: using server side cursor