Re: Understanding memory usage

From: Damiano Albani <damiano(dot)albani(at)gmail(dot)com>
To: psycopg <psycopg(at)postgresql(dot)org>
Subject: Re: Understanding memory usage
Date: 2013-10-30 17:24:59
Message-ID: CAKys9521rbsAVDk+h2xc2fdNs9-XXRuFJJEGh7ozc6MELU+m1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hello,

On Tue, Oct 29, 2013 at 12:23 AM, Daniele Varrazzo <
daniele(dot)varrazzo(at)gmail(dot)com> wrote:

>
> Because the result is returned to the client as the response for the
> query and is stored inside the cursor. fetch*() only return it to
> Python.
>

So why does calling "fetch*()" uses *additional* memory then? Does it copy
the data returned from the database?

By the way,* *I've re-run my tests but focused on the Vm*RSS* metric, which
represents how much actual physical memory is used by the process.

And I got the same behavior, that is almost no memory is reclaimed after
having fetched a *large* number of rows.
For instance, if I fetch 2 millions small rows, memory usage peaks around
500 MB and then only lowers to ~ 450 MB after data is freed.
On the other hand, fetching 100 large rows amounts to a 3 GB peak, which
subsequently falls back to 10 MB.

So is it a problem related to Psycopg itself or rather how Python handles
memory in general?

Regards,

--
Damiano Albani

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2013-10-30 18:27:15 Re: Understanding memory usage
Previous Message Daniele Varrazzo 2013-10-28 23:23:11 Re: Understanding memory usage