queries and inserts

From: Rini Dutta <rinid(at)rocketmail(dot)com>
To: pgsql-sql(at)hub(dot)org
Cc: pgsql-hackers(at)hub(dot)org
Subject: queries and inserts
Date: 2000-08-25 19:20:59
Message-ID: 20000825192059.3873.qmail@web2901.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Hi,

I am interested in how to speed up storage. About 1000
or more inserts may need to be performed at a time ,
and before each insert I need to look up its key from
the reference table. So each insert is actually a
query followed by an insert.

The tables concerned are :
CREATE TABLE referencetable(idx serial, rcol1 int4 NOT
NULL, rcol2 int4 NOT NULL, rcol3 varchar(20) NOT
NULL, rcol4 varchar(20), PRIMARY KEY(idx) ...
CREATE INDEX index_referencetable on
referencetable(rcol1, rcol2, rcol3, rcol4);

CREATE TABLE datatable ( ref_idx int4,
start_date_offset int4 NOT NULL, stop_date_offset int4
NOT NULL, dcol4 float NOT NULL, dcol5 float NOT NULL,
PRIMARY KEY(ref_idx, start_date_offset), CONSTRAINT c1
FOREIGN KEY(ref_idx) REFERENCES referencetable(idx) );

I need to do the following sequence n number of times
-
1. select idx (as key) from referencetable where
col1=c1 and col2=c2 and col3=c3 and col4=c4; (Would an
initial 'select into temptable' help here since for a
large number of these queries 'c1' and 'c2'
comnbinations would remain constant ?)
2. insert into datatable values(key, ....);

I am using JDBC interface of postgresql-7.0.2 on
Linux. 'referencetable' has about 1000 records, it can
keep growing. 'datatable' has about 3 million records,
it would grow at a very fast rate. Storing 2000
records takes around 75 seconds after I vacuum
analyze. (before that it took around 40 seconds - ???)
. I am performing all the inserts ( including the
lookup) as one transaction.

Thanks,
Rini

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-08-25 20:07:02 Proposal for supporting outer joins in 7.1
Previous Message Alfred Perlstein 2000-08-25 18:35:49 Re: Performance on inserts

Browse pgsql-sql by date

  From Date Subject
Next Message Lalit 2000-08-26 05:30:11 Sql and paradox
Previous Message Jackson Ching 2000-08-25 16:37:57 Getting the result of a query using COUNT(*)