Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C495B1337A5D for ; Tue, 3 May 2011 13:05:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 55190-01 for ; Tue, 3 May 2011 16:05:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cooker.cnx.rice.edu (cooker.cnx.rice.edu [168.7.5.70]) by mail.postgresql.org (Postfix) with ESMTP id 83BAB13364DE for ; Tue, 3 May 2011 13:05:41 -0300 (ADT) Received: from reedstrm by cooker.cnx.rice.edu with local (Exim 4.69) (envelope-from ) id 1QHI6U-0000xa-0i for pgsql-admin@postgresql.org; Tue, 03 May 2011 11:05:38 -0500 Date: Tue, 3 May 2011 11:05:38 -0500 From: "Ross J. Reedstrom" To: pgsql-admin@postgresql.org Subject: Re: simple question about using an empty string building a partial index Message-ID: <20110503160537.GA434@rice.edu> References: <4DBFA533.6080700@lelarge.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DBFA533.6080700@lelarge.info> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/30 X-Sequence-Number: 37467 On Tue, May 03, 2011 at 08:48:19AM +0200, Guillaume Lelarge wrote: > On 05/03/2011 05:52 AM, Tom Hartnett wrote: > > can it be done? > > > > create index my_idx on my_table(col1) where col1=''; > > > > ERROR: invalid input syntax for integer: "" > > > > Seems simple enough but I don't know what the trick is. > > > > col1 is an integer, not a string. And you cannot check for empty string > in an integer column. So if you've got a lot of records that display that column as an emtpy string, it's actually probably filled with a NULL, so your index create command would be something like: create index my_idx on my_table(col1) where col1 is null; Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Systems Engineer & Admin, Research Scientist phone: 713-348-6166 Connexions http://cnx.org fax: 713-348-3665 Rice University MS-375, Houston, TX 77005 GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE