Dear Martijn,
The problem with your solution is that the script is meant to process a
log-file real-time.
Therefore the insert should be done immediately, however it is the same
statement over and over agian, just with different parameters i.e. an ideal
case fore PREPARE.
Yours,
Aarjan Langereis
Ps. I recieved your reply as an attechment in the email ?
> I think your speed is being limited by backend startup time and
> transaction commit time more than anything else. I don't think prepared
> statements will help in your case.
>
> The way I usually do it is pipe the output of a whole loop to psql like
> so:
>
> for i in blah ; do
> echo "insert into ..."
> done | psql -q
>
> Or more commonly, just have the script emit all the commands to stdout
> and then run it like so:
>
> ./myscript | psql -q
>
> An important way to increase speed would be to use explicit
> transactions (BEGIN/END). When executing a lot of statements this will
> speed up things considerably. Finally, if it's just INSERTs, consider
> using COPY, for even more efficiency.
>