X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 32C84D1B23E for ; Tue, 18 May 2004 13:08:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 67445-06 for ; Tue, 18 May 2004 13:07:57 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id BB241D1B232 for ; Tue, 18 May 2004 13:07:56 -0300 (ADT) Received: (qmail 932 invoked by uid 500); 18 May 2004 16:12:56 -0000 Date: Tue, 18 May 2004 11:12:56 -0500 From: Bruno Wolff III To: Dan Field Cc: pgsql-sql@postgresql.org Subject: Re: Very slow search using basic pattern matching Message-ID: <20040518161256.GA911@wolff.to> Mail-Followup-To: Dan Field , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/156 X-Sequence-Number: 17870 On Tue, May 18, 2004 at 16:47:11 +0100, Dan Field wrote: > FROM > da_records > WHERE > da_records.DESCRIPTION_CY ~* '.*Aberystwyth*.' > OR > da_records.TITLE_CY ~* '.*Aberystwyth*.' > limit 100 > > Is there a better way of matching the string? (Must be case insensitive) This is going to require a sequential scan and if you aren't going to hit 100 entries near the beginning of the table, you will be effectively doing a full scan of the table. You might try looking at the tsearch2 contrib entry (a package for full text searching) as that will likely be able to help you out.