Discussion:
10,000 insert
theodore.tar
2010-01-14 16:48:40 UTC
Permalink
Hi:

I am trying to insert 10,000 records to test speed of pgSQL4RB.
Partial code below:

For i=1 to 10000

temp="INSERT INTO
"+chr(34)+"public"+chr(34)+"."+chr(34)+"TEST"+chr(34)+ "
VALUES(nextval('serial'),'Hi');"
TheCache.QueueSimpleQuery(temp)

next i

However, it only writes approx 1,900 records and then stops. I usually
get a lost connection error while in process. Any ideas how i can
ensure that all 10,000 records get processed?

Regards,

Theo
Aliacta Support
2010-01-14 17:09:58 UTC
Permalink
Hi Theo,

If you need to import records, I recommend you check out the COPY
subprotocol, that's waaaay faster than doing INSERTs. (See "Exporting
and importing (COPY TO/FROM subprotocol)" on page 76 of the manual.)

Now if you want to make sure everything gets processed, or nothing,
but not something halfway, then you have to use transactions. Check
out the PostgreSQL command BEGIN: <http://www.postgresql.org/docs/8.3/static/sql-start-transaction.html
I hope this puts you on the right track.

Cheers,

Marc

PS: I wonder why you loose your connection though, but then again you
have more code than the bit you're showing in this message.
Post by theodore.tar
I am trying to insert 10,000 records to test speed of pgSQL4RB.
For i=1 to 10000
temp="INSERT INTO
"+chr(34)+"public"+chr(34)+"."+chr(34)+"TEST"+chr(34)+ "
VALUES(nextval('serial'),'Hi');"
TheCache.QueueSimpleQuery(temp)
next i
However, it only writes approx 1,900 records and then stops. I
usually get a lost connection error while in process. Any ideas how
i can ensure that all 10,000 records get processed?
Regards,
Theo _______________________________________________
Postgresql mailing list
http://aliacta.com/mailman/listinfo/postgresql_aliacta.com
Loading...