zilch@home.se writes:
> I can't believe what a difference that made. How can it make it faster by
> putting it in a transaction? I thought that would make it slower. Like only
> a 100th of the time.
Everything is always a transaction in Postgres. If you don't say
begin/end, then there's an implicit begin and end around each individual
query. So your first set of tests were paying transaction commit
overhead for each insert.
regards, tom lane