On Wed, May 16, 2012 at 1:45 PM, Kryklia Alex <kryklia@gmail.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