Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yt2YQ-0006SB-OW for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2015 23:28:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yt2YQ-0006nd-9a for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2015 23:28:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yt2YP-0006nX-9z for pgsql-hackers@postgresql.org; Thu, 14 May 2015 23:28:37 +0000 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Yt2YM-0001oe-5K for pgsql-hackers@postgresql.org; Thu, 14 May 2015 23:28:36 +0000 Received: by wgin8 with SMTP id n8so92786248wgi.0 for ; Thu, 14 May 2015 16:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=G2Uk3v5VA0ypgG7FKUqpEhAD5g50pG15oMFf6ZM+9Es=; b=F4tylysKJqod2bvHJA555+VYCy8QmzeLy1LLh6xlvQ97Ql+jbvKqBQtE0639PKOzuC wcBfj45NKNtYQhXYgtAq+rv/FvBq2kovuscqMBPiVZPgJ8OjN1Xi3bojoc7TsFDsD8QQ XmTxFO9pYJrPUunEi4zT7RczcF4n2J5OvjY0V61DnCKq0ZQ3Xxl05tRZtoDWHxmqSN0R YLzXuXWt+JGoofXzEyVuSoS1bzZnzi/bSC7QdCIYPGT7NoSI1cirVeVQx6XN2763lVBs gOye6LKc0Gyg3GePDiOave3aQPwLwHcpRin90rR5RFLjOyXRPd3rP2WOlebhC/WbU0Ae LZBg== X-Received: by 10.181.11.193 with SMTP id ek1mr28381970wid.15.1431646112831; Thu, 14 May 2015 16:28:32 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id lh8sm723207wjc.23.2015.05.14.16.28.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 May 2015 16:28:31 -0700 (PDT) Message-ID: <55552F9D.4090603@iki.fi> Date: Fri, 15 May 2015 02:28:29 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Alexander Korotkov CC: Tomas Vondra , pgsql-hackers Subject: Re: KNN-GiST with recheck References: <20140926011800.GA8130@momjian.us> <20140929021631.GG12447@momjian.us> <20141006093609.GA12899@hasegeli.com> <5490357C.8090800@vmware.com> <54EC8D3E.2000908@2ndquadrant.com> <5553A2FF.1030501@iki.fi> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 05/14/2015 01:43 PM, Alexander Korotkov wrote: > On Wed, May 13, 2015 at 10:17 PM, Alexander Korotkov > wrote: > >> One quick comment: >>> >>> It would be good to avoid the extra comparisons of the distances, when >>> the index doesn't return any lossy items. As the patch stands, it adds one >>> extra copyDistances() call and a cmp_distances() call for each tuple (in a >>> knn-search), even if there are no lossy tuples. >> >> >> I will fix it until Friday. >> > > Attached patch is rebased against current master. Extra extra > copyDistances() call and a cmp_distances() call for each tuple are avoided > in the case of no lossy tuples. Thanks! I spent some time cleaning this up: * fixed a memory leak * fixed a silly bug in rechecking multi-column scans * I restructured the changes to IndexNext. I actually created a whole separate copy of IndexNext, called IndexNextWithReorder, that is used when there are ORDER BY expressions that might need to be rechecked. There is now some duplicated code between them, but I think they are both easier to understand this way. The IndexNext function is now as simple as before, and the IndexNextWithReorder doesn't need so many if()-checks on whether the reorder queue exists at all. * I renamed Distance to OrderByValues in the executor parts. We call the "ORDER BY x <-> y" construct an ORDER BY expression, so let's continue using that terminology. I think this is now ready for committing, but I'm pretty tired now so I'll read through this one more time in the morning, so that I won't wake up to a red buildfarm. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers