Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 4D528633609 for ; Mon, 31 Aug 2009 12:27:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 76356-10 for ; Mon, 31 Aug 2009 15:27:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og127.obsmtp.com (exprod7og127.obsmtp.com [64.18.2.210]) by mail.postgresql.org (Postfix) with SMTP id 2FB49633610 for ; Mon, 31 Aug 2009 12:27:24 -0300 (ADT) Received: from source ([209.85.219.216]) by exprod7ob127.postini.com ([64.18.6.12]) with SMTP ID DSNKSpvr2uH4GRICzxoYbL9qBK6LB4YBEtXE@postini.com; Mon, 31 Aug 2009 08:27:24 PDT Received: by mail-ew0-f216.google.com with SMTP id 12so3635572ewy.0 for ; Mon, 31 Aug 2009 08:27:22 -0700 (PDT) Received: by 10.216.29.210 with SMTP id i60mr1170137wea.84.1251732441315; Mon, 31 Aug 2009 08:27:21 -0700 (PDT) Received: from ?192.168.1.117? ([88.195.103.165]) by mx.google.com with ESMTPS id 24sm140471eyx.45.2009.08.31.08.27.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 31 Aug 2009 08:27:20 -0700 (PDT) Message-ID: <4A9BEBD6.60407@enterprisedb.com> Date: Mon, 31 Aug 2009 18:27:18 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Hans-Juergen Schoenig -- PostgreSQL CC: Martijn van Oosterhout , Tom Lane , pgsql-hackers , Zoltan Boszormenyi Subject: Re: combined indexes with Gist - planner issues? References: <4A9BBD39.2010500@cybertec.at> <543.1251726841@sss.pgh.pa.us> <4A9BD8DE.3060005@cybertec.at> <20090831142441.GA30008@svana.org> <4A9BE0D5.7060106@cybertec.at> In-Reply-To: <4A9BE0D5.7060106@cybertec.at> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-6.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4 X-Spam-Level: X-Archive-Number: 200908/2100 X-Sequence-Number: 144742 Hans-Juergen Schoenig -- PostgreSQL wrote: > my knowledge of how gist works internally is not too extensive. any > "kickstart" idea would be appreciated. If there's not too many of those common words, you can create a simple partial b-tree index for each, and handle the less common words with the gist index you have (you can drop the display_price column from the index). Another idea: Create a table containing one row for each word in each product: CREATE TABLE t_product_word (id bigint, word text, display_price numeric(10,4)); with triggers to keep it up-to-date. You can then create a regular two column b-tree index on that: CREATE INDEX idx_word_price ON t_product_word (word, display_price); And query with: SELECT p.art_number, p.title FROM t_product p INNER JOIN t_product_word pw ON p.id = pw.id WHERE pw.word = 'harddisk' ORDER BY pw.display_price DESC LIMIT 10; The t_product_word table will be huge, but with a few gigabytes of data it should still be manageable. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com