Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id AFF99B5DF04 for ; Mon, 6 Jun 2011 07:22:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 67056-04 for ; Mon, 6 Jun 2011 10:22:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id 53D45B5DECB for ; Mon, 6 Jun 2011 07:22:40 -0300 (ADT) Received: (qmail invoked by alias); 06 Jun 2011 10:22:37 -0000 Received: from fsgw.f-secure.com (EHLO [10.128.133.18]) [193.110.108.33] by mail.gmx.net (mp002) with SMTP; 06 Jun 2011 12:22:37 +0200 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX1+5t/1v8LK5Q2Qr9S0qkyvD4GtfgkCajhLIy7qs1D OE8Y+u18hf7Bqg Subject: Re: BUG #6052: ADD COLUMN - ERROR: tables can have at most 1600 columns From: Peter Eisentraut To: dinesh Cc: pgsql-bugs@postgresql.org In-Reply-To: <201106040709.p5479Roc058117@wwwmaster.postgresql.org> References: <201106040709.p5479Roc058117@wwwmaster.postgresql.org> Content-Type: text/plain; charset="UTF-8" Date: Mon, 06 Jun 2011 13:22:36 +0300 Message-ID: <1307355756.20678.1.camel@fsopti579.F-Secure.com> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 8bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/50 X-Sequence-Number: 30429 On lör, 2011-06-04 at 07:09 +0000, dinesh wrote: > I have a table which is used during data uploads, a so-called staging table. > This table has a fixed number of columns that [must] match the input CSV > file. This CSV file is uploaded using COPY command. Following the COPY, a > new column (meant for indexing) is constructed on this table using some > application logic; and dropped after that data upload cycle is over. > > After some 1500+ cycles, I get the following error: > > ERROR: tables can have at most 1600 columns > SQL state: 54011 > Context: SQL statement "ALTER TABLE stage_fo ADD COLUMN exch_ticker char > varying" > > So it appears that the command > ALTER TABLE stage_fo DROP COLUMN exch_ticker > is only producing some soft effects, not sufficient for the db engine. Yeah, a DROP COLUMN only hides the column and gradually phases it out from the storage, it doesn't remove it from the metadata storage, which is where the 1600 limit applies. So that application design is not going to work. I find it a bit suspicious that you add a column "for indexing", when you could perhaps be using an expression index.