Skip site navigation (1) Skip section navigation (2)

Re: Question aboud #80 - itersize in cursor dic

From: Kryklia Alex <kryklia(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: Question aboud #80 - itersize in cursor dic
Date: 2012-05-16 13:36:31
Message-ID: CAGv7O6N0b-xfenXSQ-7suBVrLO6Mm-LqXnZkor1MRthjWNHrhA@mail.gmail.com (view raw or flat)
Thread:
Lists: psycopg
Thank you very much, got it.

BTW, i read whole block of text 3 times (.
I'd liked to see this line added to docs:
"itersize" only changes how records are fetched from the backend, not
how they are returned

Thank you.
Sincerely,
Alex


2012/5/16 Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>:
> On Wed, May 16, 2012 at 1:45 PM, Kryklia Alex <kryklia(at)gmail(dot)com> wrote:
>> Hi,
>> Thank you for fast response.
>> Sorry, Daniel, for accidentally sending you answer.
>> As i understood, to enable debug in psycopg2 i need to recompile it?
>
> Yes, adding PSYCOPG_DEBUG to the define in setup.cfg and then running
> python with the env variable PSYCOPG_DEBUG set to something.
>
>> Now without debug:
>>
>> In [29]: cur=conn.cursor('1234')
>>
>> In [30]: cur.itersize=3
>>
>> In [31]: cur.execute("select generate_series(1,20)")
>>
>> In [32]: for i in cur: print i,'end of iteration step'
>> (1,) end of iteration step
>> (2,) end of iteration step
>> (3,) end of iteration step
>
> [...]
>
>> I assuming, that chunk of data on every iteration consists of 3 ints:
>> (1,2,3,) end of iteration step
>
> No, this is not the case.
>
>> As mentioned in docs:
>> The attribute itersize now controls how many records are fetched at
>> time during the iteration:
>> (http://initd.org/psycopg/docs/usage.html#server-side-cursors)
>> Or i misunderstood the docs?
>
> Yes, I think you got the docs wrong: itersize records are fetched from
> the backend, but iteration still yields one record at time. The entire
> paragraph reads:
>
> """
> Named cursors are also iterable like regular cursors. Note however
> that before Psycopg 2.4 iteration was performed fetching one record at
> time from the backend, resulting in a large overhead. The attribute
> itersize now controls how many records are fetched at time during the
> iteration: the default value of 2000 allows to fetch about 100KB per
> roundtrip assuming records of 10-20 columns of mixed number and
> strings; you may decrease this value if you are dealing with huge
> records.
> """
>
> "itersize" only changes how records are fetched from the backend, not
> how they are returned. I think the paragraph as a whole is clean
> enough. However, if you or anybody else can suggest a better wording,
> docs patches are welcome.
>
> -- Daniele

In response to

psycopg by date

Next:From: Daniele VarrazzoDate: 2012-05-17 15:06:27
Subject: reset implementation
Previous:From: Daniele VarrazzoDate: 2012-05-16 12:59:46
Subject: Re: Question aboud #80 - itersize in cursor dic

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group