Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 37E6063226E for ; Fri, 27 Nov 2009 12:26:38 -0400 (AST) 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 83525-01 for ; Fri, 27 Nov 2009 16:26:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from hook.sigaev.ru (hook.sigaev.ru [212.192.243.50]) by mail.postgresql.org (Postfix) with ESMTP id D236C631873 for ; Fri, 27 Nov 2009 12:26:29 -0400 (AST) Received: by hook.sigaev.ru (Postfix, from userid 1003) id 05080398F6; Fri, 27 Nov 2009 19:26:28 +0300 (MSK) Received: from xor.sai.msu.ru (toulouse.jfg-networks.net [82.224.249.154]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id 70276398F2; Fri, 27 Nov 2009 19:26:26 +0300 (MSK) Message-ID: <4B0FFDAE.4090201@sigaev.ru> Date: Fri, 27 Nov 2009 19:26:22 +0300 From: Teodor Sigaev User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.23) Gecko/20090909 SeaMonkey/1.1.18 MIME-Version: 1.0 To: Tom Lane CC: Pgsql Hackers Subject: Re: KNNGiST for knn-search (WIP) References: <4B0AC9E1.5050509@sigaev.ru> <4B0EAE0D.606@sigaev.ru> <4B0FEF06.5050703@sigaev.ru> <27610.1259336294@sss.pgh.pa.us> In-Reply-To: <27610.1259336294@sss.pgh.pa.us> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.74 tagged_above=-10 required=5 tests=BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 200911/1839 X-Sequence-Number: 150538 >> Done, IndexScan and IndexPath have separate field to store order clauses. > > Why? Isn't that redundant with the pathkey structures? We generate > enough paths during a complex planning problem that I'm not in favor > of adding unnecessary structures to them. I found two ways to add support of knn-seaech to planner - 0.4 version: add sorting clauses to restrictclauses in find_usable_indexes, and there is two issues: - find_usable_indexes could not be used to find indexes for index and bitmap scans at once, because sorting clauses will be used in bitmap scan. Full scan of index with knn-ordering on large index is much more expensive. - implied/refused predicate machinery is teached to ignore sorting clauses, but it's not so obvious: it should ignore operation returning non-boolean values - 0.4.1 version: pull sort clauses separately and merge them with regular clauses at create_indexscan_plan function. That's solves problems above Do you suggest to construct that clauses from pathkey representation? And append constructed clauses to indexquals in create_indexscan_plan? -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/