X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id A83DF9DC88D for ; Fri, 10 Feb 2006 16:41:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02334-07 for ; Fri, 10 Feb 2006 16:41:06 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by postgresql.org (Postfix) with ESMTP id 9A9C19DC826 for ; Fri, 10 Feb 2006 16:41:03 -0400 (AST) Received: by wproxy.gmail.com with SMTP id i12so629383wra for ; Fri, 10 Feb 2006 12:41:04 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=jJyqY4j7DHYoK7OvpETiP22rE/t0BsoljByQ0hqzDzDsKVNIRh6CrNv8kKoYu3PzV3Lk6/RdHy+gBblzv/TQ/Jwh/QZXtY/qQ7JVfikm4E0VubTOS1ASPhIdhwlaJdm0WFHN1uqgO2UXhZsAwjjtyt1+j/5feqkASRbW8187wvU= Received: by 10.65.210.11 with SMTP id m11mr343475qbq; Fri, 10 Feb 2006 12:41:04 -0800 (PST) Received: by 10.65.188.20 with HTTP; Fri, 10 Feb 2006 12:41:04 -0800 (PST) Message-ID: <9c89e2490602101241i6a182491l53478521f15f7f8d@mail.gmail.com> Date: Fri, 10 Feb 2006 12:41:04 -0800 From: david drummard To: pgsql-admin@postgresql.org Subject: performance question related to pgsql MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1131_16730175.1139604064484" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.763 required=5 tests=[AWL=0.120, HTML_00_10=0.642, HTML_MESSAGE=0.001] X-Spam-Score: 0.763 X-Spam-Level: X-Archive-Number: 200602/111 X-Sequence-Number: 20532 ------=_Part_1131_16730175.1139604064484 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I have an unique requirement. I have a feed of 2.5 - 3 million rows of dat= a which arrives every 1/2 an hour. Each row has 2 small string values (about 50 chars each) and 10 int values. I need searcheability and running arbitrary queries on any of these values. This means i have to create an index on every column. The feed comes in as a text file comma separated. Here is what i am planning to do 1) create a new table every time a new feed file comes in. Create table wit= h indexes. Use the copy command to dump the data into the table. 2) rename the current table to some old table name and rename the new table to current table name so that applications can access them directly. Note that these are read only tables and it is fine if the step 2 takes a small amount of time (it is not a mission critical table hence, a small downtime of some secs is fine). My question is what is the best way to do step (1) so that after the copy i= s done, the table is fully indexed and properly balanced and optimized for query. Should i create indexes before or after import ? I need to do this in shortest period of time so that the data is always uptodate. Note that incremental updates are not possible since almost every row will be changed in the new file. my table creation script looks like this create table datatablenew(fe varchar(40), va varchar(60), a int, b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, = n int, o int, p int, q real); create index fe_idx on datatablenew using hash (fe); create index va_idx on datatablenew using hash(va); create index a_idx on datatablenew (a); ...... create index q_idx on datatablenew(q); please advice. thanks vijay ------=_Part_1131_16730175.1139604064484 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I have an unique requirement. I have a feed of 2.5 - 3 million rows of data which arrives every 1/2 an hour. Each row has 2 small string values  (about 50 chars each) and 10 int values. I need searcheability and running arbitrary queries on any of these values. This means i have to create an index on every column. The feed comes in as a text file comma separated. Here is what i am planning to do

1) create a new table every time a new feed file comes in. Create table with indexes. Use the copy command to dump the data into the table.
2) rename the current table to some old table name and rename the new table to current table name so that applications can access them directly.

Note that these are read only tables and it is fine if the step 2 takes a small amount of time (it is not a mission critical table hence, a small downtime of some secs is fine).

My question is what is the best way to do step (1) so that after the copy is done, the table is fully indexed  and properly balanced and optimized for query.
Should i create indexes before or after import ? I need to do this in shortest period of time so that the data is always uptodate. Note that incremental updates are not possible since almost every row will be changed in the new file.

my table creation script looks like this

create table datatablenew(fe varchar(40), va varchar(60), a int, b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q real);
create index fe_idx on datatablenew using hash (fe);
create index va_idx on datatablenew using hash(va);
create index a_idx on datatablenew (a);
......
create index q_idx on datatablenew(q);


please advice.

thanks
vijay ------=_Part_1131_16730175.1139604064484--