Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFyun-00034g-F8 for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2020 12:09:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kFyuk-0000RB-GT for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2020 12:09:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFyuk-0000R4-5o for pgsql-hackers@lists.postgresql.org; Wed, 09 Sep 2020 12:09:26 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFyug-0006eg-Ad for pgsql-hackers@postgresql.org; Wed, 09 Sep 2020 12:09:25 +0000 Received: from [192.168.1.113] (dsl-hkibng22-54faa4-119.dhcp.inet.fi [84.250.164.119]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 1B5E11B001F0; Wed, 9 Sep 2020 15:09:17 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1599653357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wP4iPkZLSKBjsml1TLLxzABvanNwNOjhle9u1aubP5A=; b=JVbZgD/5Dss8h66GBDkgsSqPepEjpCAcVzqs5PDrBeEKZcSlrb+3dpVs9bwwSqtjJDnDbt 6OuLzw7S5cpNoQj54TX/pI5Tq0jInwsfhCSl0nyYFsZW5XTFYPbjFya6j4ODAEg1BPYspZ Kflfj12RQ7YzXo/l77K5iggQZT03iBHgWX6AEeyTV64ro+9lanw5El/5nek8jdUAfVkpTE CojGEewn7u1lWAfkkOMbJQZO3ao+ytuwE1wNnKCNAEXIIe5QJJPvfOe92qUPIwlCy/9yYY lhf+4N/BrrWvvSDePO15ZiR9LUdZq9SnfwVHYYsNe3dmPR7HDFHT+ix4ED8K2g== Subject: Re: Yet another fast GiST build To: "Andrey M. Borodin" , =?UTF-8?Q?Darafei_Kom=d1=8fpa_Praliaskouski?= Cc: Pavel Borisov , Thomas Munro , Michael Paquier , Alexander Korotkov , pgsql-hackers References: <1A36620E-CAD8-4267-9067-FB31385E7C0D@yandex-team.ru> <20191201020635.GL2355@paquier.xyz> <68F82C0C-F4E4-475B-BD25-386CF1FA2009@yandex-team.ru> <08173bd0-488d-da76-a904-912c35da446b@iki.fi> <1B32CF2B-4BB6-46DF-A84B-24CC22608EEA@yandex-team.ru> <92dceca4-28f0-2f37-7d3f-71b5e8f0bf92@iki.fi> <457812DD-A619-4742-80F3-7EFC7AF6521C@yandex-team.ru> <21D103AD-E510-4699-8BE5-D462B42A64C8@yandex-team.ru> From: Heikki Linnakangas Message-ID: <7d9158ca-d7cb-88f0-dbbd-1d5cec32b1ae@iki.fi> Date: Wed, 9 Sep 2020 15:09:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <21D103AD-E510-4699-8BE5-D462B42A64C8@yandex-team.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1599653357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wP4iPkZLSKBjsml1TLLxzABvanNwNOjhle9u1aubP5A=; b=N9lEwxtAym7jsgtyO/M4CZLMDqCeCGZrxP7pIYBU/Shei8bWGo5mMMigqOD/0kxUOdlYrb bEGnknxWEUY0QeFrvNcoLT0N7QR4sp512NiVqnQMJyC6ROKzFTusJuXTTgX/3aTcZ+1R4z 8B+EoCQBeLBoBgF6rQYfzIItQnTXlThMgzFGsgvjf8HqDz4N8xNnskF8Yv31T6KHPVpKBd srQAFUyxRlU9BkyeJ8ShG9gmXOCueJBNyOgnLrbrSlbZ149sH+B+hGc7fc4arXQxv/B1TZ pPeNglJs2WpPOGNvlaXwL7KGyFQVdo7Qk/rS2AuGgy6XzUKjK9BOjMDeuCpB6w== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1599653357; a=rsa-sha256; cv=none; b=dnEctQ8zArnVAuyiUqBtWjhFbx2nMsjByHbQaRvYvtiCVt1TzodS/EV2OtPS50Vt2aN2dm 1vhwE/a/w1h8f8ReP6BRaVNUduDOk5fiWRrXe7C5hG+NxFiYB50LrhuqSjiy2+pGehb5sy ErZ58xhnv7f728PcQk1C+eHeNi+YZa2JVMgQx4Vm3OSUZKGCbkVkXvivq6ts4+K8qiWLTu 9W8Z7rJEuPodzxL8lUifKGBlXtZ4Fv3fPIr6fe4ZgSHiLbKRctTGYr8E6YaDwI6XXlfRW0 KAqXLvSuXfMu9KdLXZ0l1SH0InsLzJi875KU6UXQf1PdrOBjS3+4a6kpJf1pyw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 09/09/2020 13:28, Andrey M. Borodin wrote: > Thanks Darafei! > >> 9 сент. 2020 г., в 12:05, Darafei Komяpa Praliaskouski >> написал(а): >> >>> How does the 'sortsupport' routine interact with >>> 'compress'/'decompress'? Which representation is passed to the >>> comparator routine: the original value from the table, the >>> compressed representation, or the decompressed representation? Do >>> the comparetup_index_btree() and readtup_index() routines agree >>> with that? >> >> Currently we pass compressed values, which seems not very good. But >> there was a request from PostGIS maintainers to pass values before >> decompression. Darafei, please, correct me if I'm wrong. Also can >> you please provide link on PostGIS B-tree sorting functions? >> >> We were expecting to reuse btree opclass for this thing. This way >> btree_gist extension will become a lot thinner. :) > > I think if we aim at reusing B-tree sort support functions we have to > pass uncompressed values. They can be a lot bigger and slower in case > of PostGIS. We will be sorting actual geometries instead of MBRs. > > In my view it's better to implement GiST-specific sort support in > btree_gist, rather than trying to reuse existing sort supports. Yeah, I don't think reusing existing sortsupport functions directly is important. The comparison function should be short anyway for performance reasons, so it won't be a lot of code to copy-paste. And if there are some common subroutines, you can put them in a separate internal functions for reuse. Using the 'compressed' format seems reasonable to me. It's natural to the gistbuild.c code, and the comparison routine can 'decompress' itself if it wishes. If the decompressions is somewhat expensive, it's unfortunate if you need to do it repeatedly in the comparator, but tuplesort.c would need pretty big changes to keep around a separate in-memory representation compare. However, you could use the sort "abbreviation" functionality to mitigate that. Come to think of it, the point z-order comparator could benefit a lot from key abbreviation, too. You could do the point -> zorder conversion in the abbreviation routine. - Heikki