Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 3D10164FCE3 for ; Sun, 16 Nov 2008 10:55:18 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 15957-05 for ; Sun, 16 Nov 2008 10:55:15 -0400 (AST) X-Greylist: delayed 00:05:00.944884 by SQLgrey-1.7.6 Received: from 27.mail-out.ovh.net (27.mail-out.ovh.net [91.121.30.210]) by mail.postgresql.org (Postfix) with SMTP id 0E94564FCAC for ; Sun, 16 Nov 2008 10:55:14 -0400 (AST) Received: (qmail 26074 invoked by uid 503); 16 Nov 2008 16:08:21 -0000 Received: from gw2.ovh.net (HELO mail54.ha.ovh.net) (213.251.189.202) by 27.mail-out.ovh.net with SMTP; 16 Nov 2008 16:08:21 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 16 Nov 2008 14:53:24 -0000 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO soyouz) (88.161.102.87) by ns0.ovh.net with SMTP; 16 Nov 2008 14:53:21 -0000 Date: Sun, 16 Nov 2008 15:54:08 +0100 To: =?utf-8?Q?Lutisch=C3=A1n_Ferenc?= , pgsql-performance@postgresql.org Subject: Re: Improve Seq scan performance From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <4917D9C3.9060001@gmail.com> Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <4917D9C3.9060001@gmail.com> User-Agent: Opera Mail/9.62 (Linux) X-Ovh-Tracer-Id: 3738269166282278633 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/140 X-Sequence-Number: 31871 > Dear List, > > I would like to improve seq scan performance. :-) > > I have many cols in a table. I use only 1 col for search on it. It is > indexed with btree with text_pattern_ops. The search method is: r like > '%aaa%' > When I make another table with only this col values, the search time is > better when the data is cached. But wronger when the data isn't in cache. > > I think the following: > - When there is a big table with many cols, the seq search is read all > cols not only searched. > - If we use an index with full values of a col, it is possible to seq > scan over the index is make better performance (lower io with smaller > data). > > It is possible to make an index on the table, and make a seq index scan > on this values? You can fake this (as a test) by creating a separate table with just your column of interest and the row id (primary key), updated via triggers, and seq scan this table. Seq scanning this small table should be fast. Of course if you have several column conditions it will get more complex. Note that btrees cannot optimize '%aaa%'. You could use trigrams.