Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u01jg-00AGaM-Nh for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Apr 2025 17:18:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u01jf-00GVPy-EN for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Apr 2025 17:18:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u01jf-00GVPp-21 for pgsql-hackers@lists.postgresql.org; Wed, 02 Apr 2025 17:18:43 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u01jc-0030U8-2T for pgsql-hackers@lists.postgresql.org; Wed, 02 Apr 2025 17:18:42 +0000 Received: from [192.168.1.112] (iptv-hkibng21-58c090-167.dhcp.inet.fi [88.192.144.167]) (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 4ZSWmV1lj2z49Pwk; Wed, 2 Apr 2025 20:18:34 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1743614315; 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=zrFSzVbvPo8MeiLHMyuMWvj7Hn0NqvWzMsCB3q4sjP8=; b=HY++pxrIgocYGP8O3KHzWJKwx/wgjgmj6ZzUjBX284MsA76e1fFbUbN0fgls90FLoW+QN6 RYu7rJvoV/mTTZ2C8QTSPotwXF4Zx0lowldxjo0cSzNhGN6JhVPel4copM9GGLs3PGL6Lx EQIHSrWrAWawrgIU4wFU+lX4u0JAVpfiCEBSdoXUbJ+YbFfKynd87W93W/8wq+94DUZzCh GI6dhzn0S4DzPZHlHlOD22HituKY2g6L1GfIo6geSlFMZWVDVSvVLWCDR2jo9pKKns0QHk LmOuVsgEpuQ0jVxOvBMTg+EkaQzMI63V6fk4nniwCA0pgaWfmN9N7OjZadOnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1743614315; 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=zrFSzVbvPo8MeiLHMyuMWvj7Hn0NqvWzMsCB3q4sjP8=; b=B6cFszRwP2L/rvlbYyIKwCKi18hzQ7tc/16p3kkOpNbztFzsnlVK6r1sKfRE2DYR2C6qEq +48+6xhLq699eZHAVrDIeZ/j6PFmaWPhIXb65O4pgE+PuPlsM227Ijj4H2GjDd7SwcTYTQ 8Y3nMI9z1PiK8rmNP8JCNI98w0UN/w1CB1CXgs9WU1xwrnB59T4VWvhMKV1WHwyZlo7Pml JL/RMM66Bf3rxLqXDD/gMKUElzwMwQqiBtrQhxLiVUpkU4gaWobZ9HrJP0lS2r+RhhyEvO IAIr1295WcLJOdYIeZUSdPKHCH17hMeL9BC3+e7xFyG9iMtnmcKeH3PA+8FD2A== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1743614315; a=rsa-sha256; cv=none; b=tcnQCGBrMI1S851YkWU493XeSTWKsZl/teEuLJHrT1NH13/TyAY5IqIaDOnct4Floz9oLd xHV5lnTTX3VHTAQc2cYzYJn6dLA7SMlCO3E27q74AjJzl4wAiBLHl5QpUF06LVesZs8rcO BV4Ja823evTO9RgC4sF1hpWCnnuqUgqz37j19yyZEkczN4K42NAnr21mkLyB3+gwvg/zh5 dtxv0KDlcSxPiFboknm/ePzRJfuntTgESZgllKt+In4K7IsHOcC7/LEOXMK8AEin8Y8YHz 0O96DQASmsEShLcRzuynvVrJ2ZNprn1LufMOobl7cfyU4aJ3DFDenzAornuu4Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: Date: Wed, 2 Apr 2025 20:18:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Add sortsupport for range types and btree_gist To: Bernd Helmle , Andrey Borodin Cc: Michael Paquier , jian he , PostgreSQL Hackers References: <7C9400DF-66FE-4308-BAD8-92FE3D0E55C6@yandex-team.ru> <0d9fbd59de15e2fc987a850c3d1f8a79a6ede825.camel@oopsware.de> <19c62e62c79b727d2c9a82eaeecfea5017001099.camel@oopsware.de> <4BADF8DD-A4D3-43AA-AA08-037F6FFA40BC@yandex-team.ru> <61128550659807032dd29c8c8a71674c818cbbb6.camel@oopsware.de> <7095B5FA-FADB-4524-B858-ECD14998710B@yandex-team.ru> <0176b173adfcff250543fe0aee2ef6137bd71953.camel@oopsware.de> <78499920f1e9ed5895423e735272ca2fdb90baf6.camel@oopsware.de> <770DB2DA-0B56-464A-87CE-5620CF12E114@yandex-team.ru> <6bd891c9e3aa12baea5c938267bdb5a1e50a299e.camel@oopsware.de> <64d324ce2a6d535d3f0f3baeeea7b25beff82ce4.camel@oopsware.de> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <64d324ce2a6d535d3f0f3baeeea7b25beff82ce4.camel@oopsware.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/03/2025 20:28, Bernd Helmle wrote: > Please find a new rebased version of this patch. Hmm, if we implement sortsupport function for GiST, we can register it for B-tree opfamily as well. The range comparison function has quite high overhead thanks to detoasting, but I'm nevertheless seeing a tiny speedup. I tested that with: setup: create table intranges (r int4range); insert into intranges select int4range(g, g+10) from generate_series(1, 1000000) g; vacuum freeze intranges; test script 'rangesort.sql': set work_mem='100 MB'; explain analyze select r from intranges order by r; test: pgbench -n -f rangesort.sql -P1 postgres -t100 On my laptop, that reports avg latency of 152 ms on master, and 149 ms latency with the patch. Nothing to write home about, but we might as well take it if we have the sortsupport function for gist anyway. So I added it for the btree opfamily too, and moved the function to rangetypes.c since it's not just for gist anymore. I Ccmmitted that part, and will start looking more closely at the remaining btree_gist parts now. -- Heikki Linnakangas Neon (https://neon.tech)