Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bdbernardy
Copy link
Contributor

The pool.stream method is prohibitively slow when working with large amounts of data because the QueryStream is configured to fetch 100 rows at a time. Being able to control the number of rows fetched would allow us to find the right balance between execution speed and memory consumption.

This PR adds a config parameter to the pool.stream method which allows us to specify the batchSize used in the QueryStream.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.97% when pulling 3b54f62 on bdbernardy:add-stream-batch-size into c6ddd79 on gajus:master.

@gajus gajus merged commit 2eb206b into gajus:master Jan 3, 2022
@gajus
Copy link
Owner

gajus commented Jan 3, 2022

Thank you

@gajus
Copy link
Owner

gajus commented Jan 3, 2022

🎉 This PR is included in version 27.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jan 3, 2022
@bdbernardy
Copy link
Contributor Author

bdbernardy commented Jan 4, 2022

Awesome! Thank you. I just tested it and it works wonders. Streaming 6 million rows now only takes 6 minutes instead of 2 hours :).

@bdbernardy bdbernardy deleted the add-stream-batch-size branch January 4, 2022 08:46
@gajus
Copy link
Owner

gajus commented Jan 4, 2022

yay, thank you for contributing

@raine
Copy link

raine commented Oct 12, 2023

Is batchSize supposed to control how many rows you get in the data event? Because I'm getting a single one even with batchSize: 1000. Or is it some internal thing?

@bdbernardy
Copy link
Contributor Author

Is batchSize supposed to control how many rows you get in the data event? Because I'm getting a single one even with batchSize: 1000. Or is it some internal thing?

It's the number of rows that you fetch from the database at a time. The higher the number, the faster it will be, but it will also increase the memory consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants