Have you seenlibpq - C LibraryFunctions Associated with the COPY CommandThis is best way to INSERT large amounts of data.
Regards, Christoph