-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make compatible with psycopg 3. #18
base: master
Are you sure you want to change the base?
Conversation
Oh wow, thx for looking into this 😸 . Will check it out later. |
@hwalinga Still I am hesitating to add this for the following reason - in my early tests about different insert/update tricks I found the new For reference also see https://gist.github.com/jerch/fd0fae0107ce7b153b7540111b2e89ab?permalink_comment_id=4097804#gistcomment-4097804. TL;DR: With [*] insert time on the interim temp table |
Did some preliminary tests with an early psycopg3 rewrite with
Thats ~186x faster than Edit: The binary format gives another 5-10% perf bonus in my first tests. So we should get |
More numbers on the psycopg3 rewrite testing different settings like BINARY/TEXT and using django methods to prepare values. Trying to utilize django's
(Note that I had to disable some fields on the model for the update for runtime comparison, as json and inet values must be decorated by their psycopg3 types prehand, which Perfwise the best combination is relying on psycopg3's auto adaption (not using In general it is a good thing to be more in line with django default features, so we prolly should use
Edit:
Maybe skip_value_preparation should also skip the sanity checks, as the values must be in line anyway... |
I made the code compatible with psycopg 3. The code now works on psycopg2 and psycopg 3.
I made a
compat_copy_from
asconnection.copy_from
is not available in psycopg 3 anymore and used that in thecopy_from
function.I made a function to get the connection's encoding on both platforms.
The Range types are now all just
Range
, so made a compatibility block that changes all different types of Range to just Range on psycopg 3.In the tests
The binary fields just return bytes now, so there is a compatible function tobytes that just returns bytes on both platforms.
The empty nested array is not anymore reduced on psycopg 3, so those tests are now skipped for psycopg 3.
Performance
I am unsure if this is as performant as possible on psycopg 3, but at least it is now compatible with both platforms.