Skip to content

Adjust fetch size on queries #2097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
glena opened this issue Feb 4, 2020 · 7 comments
Closed

Adjust fetch size on queries #2097

glena opened this issue Feb 4, 2020 · 7 comments
Labels

Comments

@glena
Copy link

glena commented Feb 4, 2020

Hi, we are suffereing from hight ClientWaits and one thing we would like to try is to make the fetch size bigger when we receive many results from the query. I cannot find anything related to this in the docs or the code (to be honest I have to dig deeper yet), is there any way to play with this value?

Am I right to assume this rows (https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/query.js#L27) config defined the amount of rows to fetch by the cursor each time? I dont find docs around this

@brianc
Copy link
Owner

brianc commented Feb 4, 2020 via email

@glena
Copy link
Author

glena commented Feb 4, 2020

I am talking about the analogous to this JDBC configuration. At this point we are running out of ideas and experimenting with a setting as such will help us to tune or discard the hypothesis
https://medium.com/@FranckPachot/oracle-postgres-jdbc-fetch-size-3012d494712

@brianc
Copy link
Owner

brianc commented Feb 4, 2020 via email

@glena
Copy link
Author

glena commented Feb 7, 2020

I have being playing with this and works as expected (probably is worth documenting). PG will split the results into batches of x rows which helps avoiding flooding the consumer on large result-sets (or unbounded queries). It is not helping our particular case as we were under the assumption that by default it will use a small batch (as the java driver does) but turns out it just gets everything from one transfer.

I could not test fast-connection yet, what is the current status? is it production ready or you are still polishing out?

what is the main differences between both?

Thank you!

@siddhsql
Copy link

siddhsql commented May 6, 2023

ping. same question here. does this library have anything analogous to jdbc setfetchsize? ref: https://stackoverflow.com/questions/1318354/what-does-statement-setfetchsizensize-method-really-do-in-sql-server-jdbc-driv

@proddata
Copy link

proddata commented May 8, 2023

ping. same question here. does this library have anything analogous to jdbc setfetchsize? ref: https://stackoverflow.com/questions/1318354/what-does-statement-setfetchsizensize-method-really-do-in-sql-server-jdbc-driv

You can use a Cursor which afaik is eqv: https://node-postgres.com/apis/cursor
JDBC Fetch Size afaik also uses the extended queries and server side cursors/portals:
https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY

@brianc
Copy link
Owner

brianc commented May 8, 2023

You can use a Cursor which afaik is eqv: https://node-postgres.com/apis/cursor
This is the answer. Use a cursor if you don't want all the results read into memory at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants