X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 51D759FADD1 for ; Mon, 12 Jun 2006 23:58:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 09032-03 for ; Mon, 12 Jun 2006 23:58:14 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by postgresql.org (Postfix) with ESMTP id 5C3FB9FA5FC for ; Mon, 12 Jun 2006 23:58:16 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id m2so2655254ugc for ; Mon, 12 Jun 2006 19:58:13 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=tGNFElMfvwALm0gnuWcjl6YhoI+wwJ9TPM69YRBSqqDS7S1aVD/WN85CrM/A7BiUqg/gaDUxj6HLJJCf1Vsw6KJwiSXlH1Dl+cRYqTFsFe+MznxgufHIt2tSbSF2AZqrgJMy6Zxtaq/D65due6ObfW7pMFuf4LPfDLt32Je5SzY= Received: by 10.67.30.6 with SMTP id h6mr5852186ugj; Mon, 12 Jun 2006 19:58:13 -0700 (PDT) Received: by 10.67.20.12 with HTTP; Mon, 12 Jun 2006 19:58:13 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2006 21:58:13 -0500 From: "Aaron Bono" To: "Tom Lane" Subject: Re: COPY to table with array columns (Longish) Cc: phillips@weatherbeeta.com.au, pgsql-sql@postgresql.org In-Reply-To: <14241.1150158614@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_22229_7466969.1150167493010" References: <003901c68e7a$4833dab0$9b0014ac@ITPhil> <14241.1150158614@sss.pgh.pa.us> X-Google-Sender-Auth: b061a91031753c60 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/126 X-Sequence-Number: 25362 ------=_Part_22229_7466969.1150167493010 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I agree with Tom. Personally I cannot think of a time I would use an array column over a child table. Maybe someone can enlighten me on when an array column would be a good choice. What language are you using to do the export if I may ask? -Aaron On 6/12/06, Tom Lane wrote: > > "Phillip Smith" writes: > > The whole sys file is variable length records like this - they range = > > from 1 > > to over 17,000 fields per record. > > 17000? I think you really need to rethink your schema. While you could > theoretically drop 17000 elements into a PG array column, you wouldn't > like the performance --- it'd be almost unsearchable for instance. > > I'd think about two tables, one with a single row for each SYS record > from the original, and one with one row for each detail item (the > invoice numbers in this case). With suitable indexes and a foreign key > constraint, this will perform a lot better than an array-based > translation. > > And no, in neither case will you be able to import that file without > massaging it first. > > regards, tom lane > ------=_Part_22229_7466969.1150167493010 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I agree with Tom.  Personally I cannot think of a time I would use an array column over a child table.  Maybe someone can enlighten me on when an array column would be a good choice.

What language are you using to do the export if I may ask?

-Aaron

On 6/12/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Phillip Smith" <phillips@weatherbeeta.com.au> writes:
> The whole sys file is variable length records like this - they range =
> from 1
> to over 17,000 fields per record.

17000?  I think you really need to rethink your schema.  While you could
theoretically drop 17000 elements into a PG array column, you wouldn't
like the performance --- it'd be almost unsearchable for instance.

I'd think about two tables, one with a single row for each SYS record
from the original, and one with one row for each detail item (the
invoice numbers in this case).  With suitable indexes and a foreign key
constraint, this will perform a lot better than an array-based
translation.

And no, in neither case will you be able to import that file without
massaging it first.

                        regards, tom lane

------=_Part_22229_7466969.1150167493010--