Skip to content
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

857 large downloads stream #2877

Closed
wants to merge 4 commits into from
Closed

Conversation

entantoencuanto
Copy link
Member

Related to #2774

✌️ What does this PR do?

  • Tests different alternatives to download large query results, using streaming:
    • With an enumerator
    • Using ActionController::Live
  • The streaming option is only available for json and csv formats

🔍 How should this be manually tested?

In addition to the normal endpoint there are two new endpoints that return the data in streaming:
For example:

  • Normal request: /api/v1/data/data.{csv|json}?sql=select%20*%20from%20renfe_ave%20limit%202000
  • Stream with enumerator request: /api/v1/data/stream_data.{csv|json}?sql=select%20*%20from%20renfe_ave%20limit%202000
  • Stream using ActionController::Live: /api/v1/data/live_stream_data.{csv|json}?sql=select%20*%20from%20renfe_ave%20limit%202000

:shipit: Does this PR changes any configuration file?

No

(Changes in these files might need to update the role in Ansible)

📖 Does this PR require updating the documentation?

No

@entantoencuanto
Copy link
Member Author

Unfortunately the option of using PG::Result#stream_each seems to fail when another request is sent to the database because set_single_row_mode is disabled. I've chosen to use the normal query and iterate on the result using each or each_row (these functions don't support batches, to improve the response time we could explore a way to implement it)

With the use of each and each_row without streaming the response is slower (about 10%-20%)

@ferblape ferblape closed this Nov 20, 2020
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.

None yet

2 participants