Skip site navigation (1) Skip section navigation (2)

Re: Best way to import data in postgresl (not "COPY")

From: "Jeff Crumbley" <jeffc(at)iils(dot)com>
To: "Denis BUCHER" <dbucherml(at)hsolutions(dot)ch>,<pgsql-odbc(at)postgresql(dot)org>
Subject: Re: Best way to import data in postgresl (not "COPY")
Date: 2009-07-22 19:39:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-odbc
That would depend on amount of control you have over the data source.
Your problem may be that the fields you are filtering on the data source
are not indexed and therefore the query would do a full table scan on
the source before returning records to load.  Knowing your main slow
down is number of records going between your systems, looking into this
may provide you some additional gains.

Below are three methods I am currently using to pass records between
1. You can Pull from the data source (the method you are currently
2. You can Push from the data source (in our case we load a temp table
on 	the receiving machine with just the records we need, once the
temp 	table has been loaded a process periodically updates the main
table 	from our temp table and deletes the records from or updates a
flag in 	the temp table)
3. You can Push records in a text file between the systems using FTP and
programmatically load the records in code (skipping ODBC).

Regardless of the method you use, I you are moving lots of records
between systems you might want to consider staging the data periodically
into a temp table based on some factor (date/time/indicator of your
choosing) that you can then use to load into your production table(s)
using a Select into.

Not knowing where the time factor is impacting you hopefully this gives
you some additional possibilities to consider.

Good luck,

-----Original Message-----
From: pgsql-odbc-owner(at)postgresql(dot)org
[mailto:pgsql-odbc-owner(at)postgresql(dot)org] On Behalf Of Denis BUCHER
Sent: Wednesday, July 22, 2009 1:31 PM
To: pgsql-odbc(at)postgresql(dot)org
Subject: [ODBC] Best way to import data in postgresl (not "COPY")


I have a system that must each day import lots of data from another one.
Our system is in postgresql and we connect to the other via ODBC.

Currently we do something like :

foreach row {
INSERT INTO postgresql

The problem is that this method is very slow...

More especially that for each row we do :
field1 = ...
field2 = ...
And then
$sql_insert = "INSERT ..." . field1 ....

Does someone has a better suggestion ?

Thanks a lot in advance !


In response to

pgsql-odbc by date

Next:From: Sufficool, StanleyDate: 2009-07-23 00:06:42
Subject: Re: Best way to import data in postgresl (not "COPY")
Previous:From: Denis BUCHERDate: 2009-07-22 18:31:18
Subject: Best way to import data in postgresl (not "COPY")

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group