On Tue, Jan 06, 2004 at 10:50:57 -0000,
Daryl Shanley <Daryl.Shanley@newcastle.ac.uk> wrote:
> I have some c code that writes results directly to a file as they're
> produced during a simulation. I want to modify the code to write
> directly to a postgres database using libpq. I think I could open a
> connection and insert into the database with a transaction, commiting at
> the end of the simulation. One problem with this approach is that if I
> have a lot of simultaneous simulations running I may run into problems
> with exceeding the maximum number of connections allowed. I would
> welcome any advice
I think it would be more normal to write the information to files and
then have a cleanup process insert those files into the database and
delete the files. This will keep you from having long running transactions
help open for the duration of a simulation. If you don't want a separate
cleanup process, you could have the simulation process take care of
importing the data after the calculations have been completed.