Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 40CD1632BB6 for ; Mon, 5 Apr 2010 13:23:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 11568-04 for ; Mon, 5 Apr 2010 16:23:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 851746328C5 for ; Mon, 5 Apr 2010 13:23:02 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o35GMwm7023157; Mon, 5 Apr 2010 12:22:58 -0400 (EDT) To: Andres Freund cc: pgsql-performance@postgresql.org, Oliver Kindernay Subject: Re: Huge table searching optimization In-reply-to: <201004051810.57673.andres@anarazel.de> References: <201004051810.57673.andres@anarazel.de> Comments: In-reply-to Andres Freund message dated "Mon, 05 Apr 2010 18:10:57 +0200" Date: Mon, 05 Apr 2010 12:22:58 -0400 Message-ID: <23156.1270484578@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.464 tagged_above=-10 required=5 tests=AWL=0.135, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201004/39 X-Sequence-Number: 38289 Andres Freund writes: > On Monday 05 April 2010 16:28:35 Oliver Kindernay wrote: >> i am using this request: >> select url from test2 where url ~* '^URLVALUE\\s*$'; > Depending on your locale it might be sensible to create a text_pattern_ops > index - see the following link: > http://www.postgresql.org/docs/current/static/indexes-opclass.html text_pattern_ops won't help for a case-insensitive search. The best bet here would be to index on a case-folded, blank-removed version of the url, viz create index ... on (normalize(url)) select ... where normalize(url) = normalize('URLVALUE') where normalize() is a suitably defined function. Or if it's okay to only store the normalized form of the string, you could simplify that a bit. regards, tom lane