X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 49F9F329CFB for ; Fri, 10 Sep 2004 07:25:50 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37847-01 for ; Fri, 10 Sep 2004 06:25:44 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 33DD4329CBC for ; Fri, 10 Sep 2004 07:25:44 +0100 (BST) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id i8A5dXCC003784; Fri, 10 Sep 2004 08:39:33 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id i8A5dX3f003780; Fri, 10 Sep 2004 08:39:33 +0300 Date: Fri, 10 Sep 2004 08:39:33 +0300 (EEST) From: Achilleus Mantzios To: Theo Galanakis Cc: "'Josh Berkus'" , Subject: Re: Isnumeric function? In-Reply-To: <82E30406384FFB44AFD1012BAB230B55037D0591@shiva.au.lpint.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/71 X-Sequence-Number: 18917 O Theo Galanakis έγραψε στις Sep 10, 2004 : > > > Josh, > > I agree with the machete technique, unfortunately The structure is inplace > and a work-around was required. > > I created the Index you specified, however it chooses to run a seq scan on > the column rather than a Index scan. How can you force it to use that > Index.. > > CREATE INDEX idx_content_numeric ON botched_table(content) WHERE content ~ > '^[0-9]{1,9}$'; > > select * from botched_table where content = 200::integer EXPLAIN ANALYZE is your friend. VACUUM [FULL] ANALYZE also. Try with 200::text In the end if there is an option for the planner to use the index but he doesn't, then maybe its not worth it. > > Theo > -----Original Message----- > From: Josh Berkus [mailto:josh@agliodbs.com] > Sent: Friday, 10 September 2004 4:46 AM > To: Theo Galanakis; pgsql-sql@postgresql.org > Subject: Re: [SQL] Isnumeric function? > > > Theo, > > > Does anyone have any better suggestions??? > > Well, one suggestion would be to take a machete to your application. > Putting > key references and text data in the same column? Sheesh. > > If that's not an option, in addition to the approach you've taken, you could > > also do a partial index on the appropriate numeric values: > > CREATE INDEX idx_content_numeric ON botched_table(content) WHERE content ~ > '^[0-9]{1,9}$'; > > However, this approach may be more/less effective that the segregation > approach you've already taken. > > -- -Achilleus