In the search for paging using psycopg2 I discovered the attributes cursor.itersize and cursor.arraysize , and the methods cursor.fetchmany () and cursor.scroll ()
I wanted to check with the staff here if my understanding is correct about these methods and attributes.
fetchmany()
returns many rows, whose quantity can be passed as parameter.
scroll()
by what I understand is to scroll the cursor to some position among the lines loaded by the query, but I did not understand the parameter that it receives.
The itersize
attribute, as I understand it, controls the number of lines that the cursor should receive from the database. Maybe behind the driver is making use of the parameter LIMIT
of postgresql that limits the amount of rows that should be returned by the query.
The arraysize
attribute defines the number of rows that will be returned by the fetchmany()
method. I do not understand the purpose of this attribute on the object, since the fetchmany()
method already receives a parameter to define this.
I need to display the rows of a table in a gui table component, some api graphics that I have not decided yet. But I think it is more appropriate that I make use of these attributes and methods to create a pagination, because creating a cursor
object with all the data of a table that has many records can consume many resources.