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

Fix jdbc_fetch_size usage with postgresql (#103) #200

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

izhigalko
Copy link

@izhigalko izhigalko commented Apr 7, 2017

According to documentation (https://jdbc.postgresql.org/documentation/head/query.html) we need to autocommit off if setFetchSize is used. So i wrap statement execution in transaction with Sequel::JDBC::Transaction cls and rollback transaction after all.

@karmi
Copy link

karmi commented Apr 7, 2017

Hi @izhigalko, we have found your signature in our records, but it seems like you have signed with a different e-mail than the one used in yout Git commit. Can you please add both of these e-mails into your Github profile (they can be hidden), so we can match your e-mails to your Github profile?

@izhigalko
Copy link
Author

Hi @izhigalko, we have found your signature in our records, but it seems like you have signed with a different e-mail than the one used in yout Git commit. Can you please add both of these e-mails into your Github profile (they can be hidden), so we can match your e-mails to your Github profile?

Thanks. I added and verified second email to my profile.

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an awesome PR. I've listed some possible improvements.

@@ -205,26 +207,29 @@ def execute_statement(statement, parameters)
query = @database[statement, parameters]
sql_last_value = @use_column_value ? @sql_last_value : Time.now.utc
@tracking_column_warning_sent = false
@logger.debug? and @logger.debug("Executing JDBC query", :statement => statement, :parameters => parameters, :count => query.count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was :count removed? Did it execute an extra COUNT or was there some other reason?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Count removed cause it slow down huge queries execution when debug enabled. My query have more than 5 subqueries in fields and i wait count execution about 5 hours before remove it.

if @jdbc_paging_enabled
query.each_page(@jdbc_page_size) do |paged_dataset|
paged_dataset.each do |row|
@database.transaction do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for describing this change in the PR. We really need this documented here as well.

Do you know how this will play with other databases? I'm not anticipating problems ATM, but I'm curious what your thoughts are. I'm wondering if this codepath should be PG only.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its ok with other dbs cause used standard JDBC transaction mechanic with Sequel::JDBC::Transactions, and all dbs that i knew uses transaction mechanic. I can rewrite code for use only with PG driver if u wish.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@izhigalko no, I think that makes sense. I do think it needs a comment to explain why we wrap with a transaction then rollback for seemingly no reason however. If you put that comment in we can move forward :)

@andrewvc
Copy link
Contributor

andrewvc commented May 3, 2017

@izhigalko if you can just add in that comment I think we can move forward :)

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@izhigalko it looks like the build is failing: https://travis-ci.org/logstash-plugins/logstash-input-jdbc/builds/228698596?utm_source=github_status&utm_medium=notification Can you take a look and fix? We'll need a passing build to merge :)

@symbyte
Copy link

symbyte commented May 11, 2017

I'm very interested in seeing this move forward. I cloned locally to see if I could help fix the failing test, but when I ran them they all passed. Perhaps there was an issue with the Mock Connection module in the sequel dependency that has since been resolved? It seemed really weird anyway that the the tests failed at the addition of a comment.

Any chance we could run the build on this branch again to see if the tests pass? I'm suspicious that they will...

@izhigalko
Copy link
Author

@andrewvc ok, fix this. Test failed cause it uses mock database driver which not implements all needed methods

@phillycheeze
Copy link

Possible to have this revisited? The jdbc_fetch_size still doesn't work for postgresql.

@caseydm
Copy link

caseydm commented May 19, 2022

Hi all is jdbc_fetch_size working with postgresql now? I just using it in a project after switching from redshift and am running into memory errors. It worked great in redshift.

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.

6 participants