dump a perl array into a psql DB via 'copy'; help?

Mike Waychison mike-DlQxw/23Tq2aMJb+Lgu22Q at public.gmane.org
Wed Dec 15 18:39:29 UTC 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Madison Kelly wrote:
> Yanni Chiu wrote:
> 
>> Madison Kelly wrote:
>>
>>> ... This way I would
>>> avoid a second disk IO hit by avoiding the need to have 'psql' read the
>>> file.
>>
>>
>>
>> If you can process the files serially, or if you have enough memory,
>> you could write your files to an in-memory tmp partition (I've forgotten
>> the correct term for it), to avoid a disk write. I just looked at
>> manpages for swapon, mount, fstab, but could not find what I'm thinking
>> of, so I hope its not just a SunOS/Solaris thing.
>>
>>
>>>   My question is how can I get the same function as 'psql dbname -f
>>> data.txt' except telling 'psql' to get the values from the array
>>> instead?

Unless you are very low on memory, or are using nfs, the data shouldn't
ever be hitting the disk / network.

This is of course assuming that the file isn't opened O_SYNC and you
don't (implicitly/explicitly) call sync(2) or fsync(2).

>>
>>
>>
>> My Perl is rusty, but wouldn't piping into the psql stdin work, i.e.:
>>
>>     open(PSQL, "| psql $dbname")
>>
>> HTH.
>> --yanni
> 
> 
> That worked perfectly, I should have thought of that myself. :p
> 
> Thank you very much!
> 
> Madison
> -- 
> The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBwITgdQs4kOxk3/MRAuXZAKCRBLrZVhnfZuOQw9FKtFCR2AqLsgCfcMr/
/NN2OmzBm93/gWpFYbMeZIc=
=MdsJ
-----END PGP SIGNATURE-----
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list