On Nov 4, 3:29 am, Marco Paolini <markopaol...@gmail.com> wrote: > where/when do we close() cursors, or we rely on cursor __del__() > implementation? I guess we should rely on it going away when it happens to go away (that is, __del__ way).
> > postgres named cursors can't be used in autocommit mode [1] I don't know if there is any other way than documentation + checking this in postgresql backend's chunked_cursor method. I think there is actually a more severe limitation: the cursor is not usable outside the transaction. Or you will need to create it as "with hold" cursor, which means it can live even outside transactions, but then closing it is really important. This according to psycopg2 documentation. I really think this is documentation / sanity checking stuff. .chunked() is there because it can have weird requirements / backend specific behavior. Making it behave exactly the same way on every backend, without transaction etc requirements will make this feature really, really hard to implement. There is a tradeoff here between what can be achieved easily, and per backend requirements. > > psycopg fetches 2000 rows at the time That is luckily alterable, we can make it fetch 100 rows at a time if we want. I would think that the 2000 rows has a good balance between memory usage and network round trips. Maybe chunked could have a chunk_size kwarg, but that can wait for later. - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.