What's the behavior of psycopg2 cursor fetchmany

31 Views Asked by At

I am kind of confused about the behavior of psycopg2 cursor fetchmany method compared with paging query

Say, I have a query that will get 10000 rows in total.

When I use fetchall, I understand that the 10000 rows will be fetched back to the python process in one round.

But when I use fetchmany and the fetch size is 3000, then it will perform 4 times to get back all the 10000 rows (3000*3+1000),does the psycopg2 cursor will kick off 4 queries like the paging query does or only one query is performed but the db server is prepared for the data to be transferred in 4 rounds?

I want to use fetchmany, but I don't like the many rounds query.

Could some one help explain, thanks.

0

There are 0 best solutions below