Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C9A919FBB4E for ; Fri, 20 Apr 2007 16:43:11 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 11720-05 for ; Fri, 20 Apr 2007 16:43:08 -0300 (ADT) X-Greylist: delayed 00:58:33.937493 by SQLgrey-1.7.4 Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by postgresql.org (Postfix) with ESMTP id 91F3F9FBAF9 for ; Fri, 20 Apr 2007 16:43:08 -0300 (ADT) Received: from dhcp202.pillette.com (dhcp202.pillette.com [192.168.1.202]) by pillette.com (8.11.6/8.11.6) with ESMTP id l3KIiV410387 for ; Fri, 20 Apr 2007 11:44:32 -0700 Date: Fri, 20 Apr 2007 12:07:29 -0700 From: Andrew Lazarus X-Mailer: The Bat! (v3.98.4) Home Organization: Pillette Investment Management X-Priority: 3 (Normal) Message-ID: <1217328326.20070420120729@pillette.com> To: pgsql-performance@postgresql.org Subject: index structure for 114-dimension vector In-Reply-To: References: <01db01c781e4$c700bf30$2e00a8c0@tridecap.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.136 tagged_above=0 required=5 tests=BAYES_50=0.001, FORGED_RCVD_HELO=0.135 X-Spam-Level: X-Archive-Number: 200704/350 X-Sequence-Number: 24227 I have a table with 2.5 million real[] arrays. (They are points in a time series.) Given a new array X, I'd like to find, say, the 25 closest to X in some sense--for simplification, let's just say in the usual vector norm. Speed is critical here, and everything I have tried has been too slow. I imported the cube contrib package, and I tried creating an index on a cube of the last 6 elements, which are the most important. Then I tested the 2.5MM rows for being contained within a tolerance of the last 6 elements of X, +/- 0.1 in each coordinate, figuring that would be an indexed search (which I CLUSTERED on). I then ran the sort on this smaller set. The index was used, but it was still too slow. I also tried creating new columns with rounded int2 values of the last 6 coordinates and made a multicolumn index. For each X the search is taking about 4-15 seconds which is above my target at least one order of magnitude. Absolute numbers are dependent on my hardware and settings, and some of this can be addressed with configuration tweaks, etc., but first I think I need to know the optimum data structure/indexing strategy. Is anyone on the list experienced with this sort of issue? Thanks. Andrew Lazarus andrew@pillette.com