Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id AA0619F9E4A for ; Tue, 2 Oct 2007 19:23:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 11595-04 for ; Tue, 2 Oct 2007 19:23:43 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by postgresql.org (Postfix) with ESMTP id 54E4D9F9FE4 for ; Tue, 2 Oct 2007 19:23:48 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.1/8.14.1) with ESMTP id l92MNhXg012116 for ; Tue, 2 Oct 2007 19:23:43 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.1/8.14.1/Submit) id l92Ltb9R093116 for pgsql-performance@postgresql.org; Tue, 2 Oct 2007 18:55:37 -0300 (ADT) (envelope-from news) From: Chris Browne X-Newsgroups: pgsql.performance Subject: Re: performance of like queries Date: Tue, 02 Oct 2007 17:55:08 -0400 Organization: cbbrowne Computing Inc Lines: 31 Message-ID: <60abr1mbb7.fsf@dba2.int.libertyrms.com> References: <200710021131.46010.kevin@kevinkempterllc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.20 (linux) Cancel-Lock: sha1:FkEalzHaAiIwafqlMueCgqZ2qZI= To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/11 X-Sequence-Number: 27033 kevin@kevinkempterllc.com (Kevin Kempter) writes: > any suggestions for improving "LIKE '%text%'" queries? If you know that the 'text' portion of that query won't change, then you might create a partial index on the boolean condition. That is, create index index_foo_text on my_table (tfield) where (tfield like '%text%'); I somehow doubt that is the case; more likely you want to be able to search for: select * from my_table where tfield like '%this%'; select * from my_table where tfield like '%that%'; select * from my_table where tfield like '%the other thing%'; There are basically three choices, at that point: 1. Get more memory, and hope that you can have all the data get cached in memory. 2. Get more better disk, so that you can scan the table faster on disk. 3. Look into tsearch2, which provides a full text search capability. -- (format nil "~S@~S" "cbbrowne" "linuxdatabases.info") http://cbbrowne.com/info/x.html "We're born with a number of powerful instincts, which are found across all cultures. Chief amongst these are a dislike of snakes, a fear of falling, and a hatred of popup windows" -- Vlatko Juric-Kokic