Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 244909FB4F4 for ; Fri, 2 Mar 2007 00:23:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 03971-01 for ; Fri, 2 Mar 2007 00:23:35 -0400 (AST) X-Greylist: delayed 00:24:58.624444 by SQLgrey-1.7.4 Received: from cenn.mc.mpls.visi.com (cenn.mc.mpls.visi.com [208.42.156.9]) by postgresql.org (Postfix) with ESMTP id F25309FB4EB for ; Fri, 2 Mar 2007 00:23:34 -0400 (AST) Received: from [172.16.1.10] (adsl-71-146-131-14.dsl.pltn13.sbcglobal.net [71.146.131.14]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by cenn.mc.mpls.visi.com (Postfix) with ESMTP id 4BC9B81D0 for ; Thu, 1 Mar 2007 21:58:34 -0600 (CST) Message-ID: <45E7A108.9010802@mithral.com> Date: Thu, 01 Mar 2007 19:59:04 -0800 From: Adam L Beberg User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Array indexes, GIN? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200703/44 X-Sequence-Number: 23449 I need to cross reference 2 tables. There are O(10M) A's, each has an ordered set of 10 of the O(100K) B's associated with it. The dominant query will be finding the A's and their count associated with a given list of ~1k B's i.e. if 2 of the listed B's are in A's set of 10, it's (A,2), and we should get back ~100K rows. The good news is we only need to run this brutal query every couple minutes, but the row updates will flow fast. Luckily this is PostgreSQL, so the simple solution seems to be CREATE TABLE xref( A bigint, B bigint[10] ); -- A is primary key which cuts down the table overhead. O(10M) rows w/array. On the surface, looks like a job for GIN, but GIN seems undocumented, specifically mentions it doesn't support the deletes we'll have many of since it's designed for word searching apparently, the performance implications are undocumented. I searched, I read, and even IRC'd, and it seems like GIN is just not used much. Is GIN right? Will this work at all? Will it run fast enough to function?