drastic reduction in speed of inserts as the table grows

From: Rini Dutta <rinid(at)rocketmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: pgsql-general(at)postgresql(dot)org, pgsql-interfaces(at)postgresql(dot)org
Subject: drastic reduction in speed of inserts as the table grows
Date: 2001-04-17 14:28:53
Message-ID: 20010417142853.64642.qmail@web12507.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces pgsql-sql

Hi,

I was comparing speed of inserts in C vs JDBC and
found that as the table size increases the speed
differential decreases till there is no difference (no
problem). However inserts kept getting slower and
slower as the table size increased and the performance
became quite poor. Here is the data including the
table descriptions -
CREATE TABLE some_table(
idx serial,
a_idx int4 NOT NULL,
b_idx int4 NOT NULL,
c_address varchar(20) NOT NULL,
d_address varchar(20) NOT NULL,
PRIMARY KEY(idx),
CONSTRAINT a_fkey1 FOREIGN KEY(a_idx)
REFERENCES a_ref(idx),
CONSTRAINT b_fkey2 FOREIGN KEY(b_idx)
REFERENCES b_ref(idx)
);
CREATE INDEX some_index on some_table (a_idx, b_idx,
c_address, d_address);

Here is the performance statistics on the same table.
Note the fall in performance as the test proceeds.

# of inserts C (in sec) JDBC (in sec)
(as 1 transaction)

500 1 1.7
1000 3 3.4
2000 6 7.5
another 6000 inserts ...
then
10000 70.8
10000 283
(ran vacuum at this point to see if it helped)
10000 355
1000 36 37
100 3.8 3.8

I ran these tests on a Linux machine (299 MHz). I used
postgres v7.0.3 but then I even tried grouping a large
number of inserts in one transaction to reduce the
number of hard-disk writes (it did not make a
difference as shown in the above data)

I am concerned about the drastic fall in performance
with increase of table size. Is this expected behavior
? Would this be related to indexes existing on the
table? I would expect indexes to make inserts slower
but I do not see how it explains such a great fall in
performance with increasing table-size. Is there a way
to avoid this drop in performance ?

Thanks,
Rini

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-04-17 14:33:15 Re: index not used with subselect in where clause ?
Previous Message Tom Lane 2001-04-17 14:24:54 Re: parse error at or near $1

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2001-04-17 15:21:22 Re: drastic reduction in speed of inserts as the table grows
Previous Message Peter T Mount 2001-04-17 13:22:13 Re: error compiling 7.1 jdbc driver

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Stosberg 2001-04-17 14:30:44 function to format floats as money?
Previous Message Anand Raman 2001-04-17 06:34:14 Re: Cursors in plpgsql