Skip to content

feat: remove prepare operation in copy from#1085

Closed
KennyChenFight wants to merge 1 commit into
jackc:masterfrom
KennyChenFight:feat/remove-prepare-in-copy-from
Closed

feat: remove prepare operation in copy from#1085
KennyChenFight wants to merge 1 commit into
jackc:masterfrom
KennyChenFight:feat/remove-prepare-in-copy-from

Conversation

@KennyChenFight

Copy link
Copy Markdown

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

jackc commented Sep 25, 2021

Copy link
Copy Markdown
Owner

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

@mixmind

mixmind commented Nov 8, 2021

Copy link
Copy Markdown

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

jackc commented Nov 8, 2021

Copy link
Copy Markdown
Owner

@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
Copy Markdown
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
Copy Markdown
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

jackc commented Dec 2, 2022

Copy link
Copy Markdown
Owner

@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
Copy Markdown
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
Copy Markdown
Contributor

@jackc I created PR #1412 for what we discussed

@rubiagatra

rubiagatra commented Jan 13, 2025

Copy link
Copy Markdown

Is this PR still relevant? @KennyChenFight, can we close it?

@jackc jackc closed this Jan 20, 2025
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