Re: multiple data to insert to database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2007-08-10 at 15:36 +0200, Alain Roger wrote:
> Hi,
> 
> I would like to know what is the best way and fastest to insert into
> PostgreSQL around 25.000 records (extracted from CSV file).
> Should i use the standard pg_exec($dbconn, "insert into..."); for each
> record ?
> 
> thanks a lot,

Let's say you have a table with an id and a value field. Where id is the
key. You should be able to stack inserts like follows:

INSERT INTO foo ( id, value ) VALUES ( 1, 'One' ), ( 2, 'Two' ), ( 3,
'threee' );

So with that in mind, you should cluster your inserts into groups of X
inserts. I few hundred should make things a little quicker for you.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux