From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | Håvard Wahl Kongsgård <haavard(dot)kongsgaard(at)gmail(dot)com> |
Cc: | psycopg <psycopg(at)postgresql(dot)org> |
Subject: | Re: Iterating through cur and cur.fetchone() |
Date: | 2011-10-10 11:26:14 |
Message-ID: | CA+mi_8ZA3b3+NbcW6uonovkJuCPn-4Kn1TNLJYEXCZ56yX6U2A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
2011/10/10 Håvard Wahl Kongsgård <haavard(dot)kongsgaard(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | thomas veymont | 2011-10-14 10:32:03 | using server side cursor |
Previous Message | Håvard Wahl Kongsgård | 2011-10-10 11:19:23 | Re: Iterating through cur and cur.fetchone() |