I have a program that will be copying large amounts of data into Postgres 9 using COPY FROM via stdin more or less continually.
This is currently working fine, but I am buffering chunks of data and then running COPY FROM operations in batches.
I am wondering, and couldn't find after looking around, whether it would be a bad idea for me to just create the COPY FROM stream and just never close it until my program terminates. As in, while my program is running and accepting new data, I would like to open a COPY FROM and continually stream that data for its lifetime.
I am looking for what the internal mechanics of that are on the Postgres end:
- Does the
COPY FROMoperation create a transaction internally? - Related: Will the data I'm streaming be immediately accessible to other sessions?
- Does Postgres have any internal mechanics that would cause this to not work (i.e. some internal state that would overflow without routine closing of the
COPY FROMstream)?
Note: I'm aware similar considerations also apply to the client side driver I'm using, but I assume (perhaps incorrectly) that the choice of client won't change what I'm asking with regard to the Postgres side of things. I'd like to keep this question focused on Postgres specifically if possible.