Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1B91BB5DBBF for ; Thu, 26 May 2011 06:31:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 40537-08 for ; Thu, 26 May 2011 09:31:14 +0000 (UTC) X-Greylist: delayed 16:31:11.796922 by SQLgrey-1.7.6 Received: from 27.mail-out.ovh.net (6.27.mail-out.ovh.net [46.105.50.195]) by mail.postgresql.org (Postfix) with SMTP id 7A29AB5D832 for ; Thu, 26 May 2011 06:31:13 -0300 (ADT) Received: (qmail 8833 invoked by uid 503); 26 May 2011 10:20:46 -0000 Received: from b9.ovh.net (HELO mail193.ha.ovh.net) (213.186.33.59) by 27.mail-out.ovh.net with SMTP; 26 May 2011 10:20:41 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 26 May 2011 11:24:26 +0200 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13) (lists%peufeu.com@88.161.102.87) by ns0.ovh.net with SMTP; 26 May 2011 11:24:25 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Stefan Keller" Cc: mmoncure@gmail.com, pgsql-performance@postgresql.org, "Robert Haas" Subject: Re: FW: KVP table vs. hstore - hstore performance (Was: Postgres NoSQL emulation) References: <4DD06EF3.7030003@postnewspapers.com.au> <99EECF01B5C87A498318776AB7E4A78D3640F59E26@sid00102.hsr.ch> Date: Thu, 26 May 2011 11:24:24 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: User-Agent: Opera Mail/11.10 (Linux) X-Ovh-Tracer-Id: 2038160308291896912 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|U 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201105/364 X-Sequence-Number: 43873 > My problem is, that in fact I don't know which tag to index since I'm > running a web admin application where users can enter arbitrary > queries. For a tag cloud, try this : - table tags ( tag_id, tag_name ) - table articles ( article_id ) - table articles_to_tags( article_id, tag_id ) now this is the classical approach, which doesn't work so well when you want to get an article that has several tags (tag intersection). So, materialize the list of tag_ids for each article in an INTEGER[] array in the articles table, kept up to date with triggers. Create a gist index on that, and use indexed array vs array operators.