-
Notifications
You must be signed in to change notification settings - Fork 100
Conversation
Hey @Samira-El or @koszti, sorry to bother you both! Would you be able to take a look at this PR for us? |
Hi @tomslade1 and @ivanovyordan, thank you for this contribution, this is a substantial change so will take a look at it some this or next week when have time. |
Can you please in the meantime make sure the PR is passing the CI checks? TY |
Thanks @Samira-El - very much appreciated 🙇 ; Will cover off the CI checks in the mean time! |
476cc3b
to
c55e952
Compare
Hey @Samira-El. I fixed a few more warnings, but it looks like the CI fails because of some config. I'm still not sure how I'm supposed to pass the |
The issue is in the method |
c03afb2
to
479eae1
Compare
Hey @Samira-El Thank you so much for helping me with this. I decided to use the original design of the project. All I do now is to extract the code of the It seems to be working well on my machine, and I really hope I did it right this time. :) |
Hey @ivanovyordan, something is wrong, the tests in CI are hanging. Can you please run the tests locally to make sure it's all good code-wise . |
Yep. Looking at it ATM. :) |
479eae1
to
bfdd989
Compare
Tap-postgres opens a new connection every time it needs to cast a value. This is highly inefficient as opening a connection is usually a slow and resource-intensive operation. An easy fix would be to use something like PgBouncer, but it's even better if we open just once connection and reuse it for all queries. An easy way to fix that is to implement Singleton, but we decided to go even simpler and store our connections in the db module we already have. All we do is to store two types of connections (transactional and logical). Every time we need a connection we check if we already have an open connection. If we don't we open it and store it. Then just return that connection.
bfdd989
to
e031bfa
Compare
Hey @Samira-El . I finally had the time to look into my changes properly. I decided to go super simple and store the two connections in the Something I'm not sure you'd like is I use global variables. Other than that, I have two failing tests, that also fail on the
|
I don't think that opening multiple connections is the problem that should be solved here. Instead, the entire remote casting should be removed (see #173). |
Problem
Tap-postgres opens a new connection every time it needs to cast a value. This is highly inefficient as opening a connection is usually a slow and resource-intensive operation.
Proposed changes
An easy fix would be to use something like PgBouncer, but it's even better if we open just one connection and reuse it for all queries.
To fix the issue we do two things:
connect
method returns the connection we need based on the arguments provided.when
statements when asking for a connection. When statements are great every time we need to ensure a resource is properly closed after it's being used, but in our specific case, we don't want to close connections after each query.Types of changes
Checklist
setup.py
is an individual PR and not mixed with feature or bugfix PRs[AP-NNNN]
(if applicable. AP-NNNN = JIRA ID)AP-NNN
(if applicable. AP-NNN = JIRA ID)