title: Postgres COPY FROM forever
body: <p>I have a program that will be copying large amounts of data into Postgres 9 using <code>COPY FROM</code> via stdin more or less continually.</p>
  
  <p>This is currently working fine, but I am buffering chunks of data and then running <code>COPY FROM</code> operations in batches.</p>
  
  <p>I am wondering, and couldn't find after looking around, whether it would be a bad idea for me to just create the <code>COPY FROM</code> 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 <code>COPY FROM</code> and continually stream that data for its lifetime.</p>
  
  <p>I am looking for what the internal mechanics of that are on the Postgres end:</p>
  
  <ul>
  <li>Does the <code>COPY FROM</code> operation create a transaction internally?</li>
  <li>Related: Will the data I'm streaming be immediately accessible to other sessions?</li>
  <li>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 <code>COPY FROM</code> stream)?</li>
  </ul>
  
  <p>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.</p>