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

feat: remove prepare operation in copy from #1085

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KennyChenFight
Copy link

I think it's not necessary to use prepare operation to set value type before copy from operation. It would produce one RTT and slow down copy from operation.

@jackc
Copy link
Owner

jackc commented Sep 25, 2021

I think that step is necessary to handle native Go values like string and int32...

@mixmind
Copy link

mixmind commented Nov 8, 2021

I have same question,

I'm using extension(pipelinedb), there is no simple select from table that pgx tries to prepare statement.
This extension creates foreign table and simple select from it can only throw error, that it's stream and not a table.
This table only in use for inserts, or creating view from it.

Removing prepare statements would help for me too.
Can you please suggest some workaround , that I could use COPY too?

@jackc
Copy link
Owner

jackc commented Nov 8, 2021

@mixmind You could drop down to the pgconn level and construct the copy stream manually. See https://pkg.go.dev/github.com/jackc/pgconn#PgConn.CopyFrom.

@bfontaine
Copy link
Contributor

@KennyChenFight any thought on Jack’s comment?

@bfontaine bfontaine added the needs response Needs a response from the issue/PR author label Oct 25, 2022
@alejandrodnm
Copy link
Contributor

Hi @jackc we are using CopyFrom in a write intensive application. I wanted to get rid of the prepare statement, would you accept a PR that exposes a new CopyFromWithStatementDescription method that accepts a pgconn.StatementDescription as argument?

@jackc
Copy link
Owner

jackc commented Dec 2, 2022

@alejandrodnm I don't mind an improvement to copy from performance, but I'm not convinced that a CopyFromWithStatementDescription is the correct approach.

What about CopyFrom using the automatic statement or description caching like Query does? Then everyone would benefit automatically. Detecting / handling schema changes might be tricky though.

@alejandrodnm
Copy link
Contributor

Sounds good @jackc , I'll give it a try.

Thanks

@bfontaine bfontaine removed the needs response Needs a response from the issue/PR author label Dec 2, 2022
@alejandrodnm
Copy link
Contributor

@jackc I created PR #1412 for what we discussed

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.

5 participants