Re: Perfomance Tuning - Mailing list pgsql-performance

From Ron Johnson
Subject Re: Perfomance Tuning
Date
Msg-id 1060770827.30778.130.camel@haggis
Whole thread Raw
In response to Re: Perfomance Tuning  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-performance
On Wed, 2003-08-13 at 01:47, Christopher Kings-Lynne wrote:
> > So, group the inserts in transactions with maybe 1000 commands each. It
> > will go much faster. It can then cache the rows and in the end just make
> > sure all 1000 have been written out on disk.
>
> More than that, he should be using COPY - it's 10x faster than even grouped
> inserts.

I have a table which has a foreign key reference to a properly indexed
table, and needed to load 15GB of uncompressed data into that table.

Since the machine is minimal (60GB 5400RPM IDE HDD, 1GB RAM, 1GHz
Athlon), to save precious disk space, I had the data compressed into
22 files totaling 641GiB.  The records are approximately 275 bytes
in size.

Also, because date transformations needed to be made, I had to 1st
insert into a temp table, and insert from there into the main table.
Thus, in essence, I had to insert each record twice.

So, in 8:45 (not 8 minutes 45 seconds!, decompressed 641MiB worth of
96% compressed files, inserted 30M rows, and inserted 30M rows again,
while doing foreign key checks to another table.  And the data files
plus database are all on the same disk.

Pretty impressive: 1,920 inserts/second.

for f in ltx_*unl.gz;
do
    psql test1 -c "truncate table t_lane_tx2;" ;
    (zcat $f | sed "s/\"//g" | \
       psql test1 -c "copy t_lane_tx2 from stdin delimiter ',';");
    time psql -a -f sel_into_ltx.sql -d test1      ;
done

--
+---------------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net           |
| Jefferson, LA  USA                                            |
|                                                               |
| "Man, I'm pretty.  Hoo Hah!"                                  |
|    Johnny Bravo                                               |
+---------------------------------------------------------------+



pgsql-performance by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: Perfomance Tuning
Next
From: Christopher Browne
Date:
Subject: Re: Perfomance Tuning