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.96) (envelope-from ) id 1wWHjm-002Vdy-0r for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jun 2026 17:56:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wWHjj-00HV6R-1q for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jun 2026 17:56:39 +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.96) (envelope-from ) id 1wWHjj-00HV6J-0q for pgsql-bugs@lists.postgresql.org; Sun, 07 Jun 2026 17:56:39 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wWHjg-00000001m0s-3ex8 for pgsql-bugs@lists.postgresql.org; Sun, 07 Jun 2026 17:56:38 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-490b4e1ade7so38350745e9.0 for ; Sun, 07 Jun 2026 10:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780854995; x=1781459795; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=wrLwqR7E52tys8PCHiVoVNwMCtyGnj9x6DF3Sfvfgds=; b=jH5Z/uDSiEiK3SHmrd++Eba4jj/tmYsZ8fy/52qIgkq+e/sxSrQdTmjUjOdFfgeYHJ H5S+UqML84LMLbr0irNZks/x86BQzpG26rtGL0F63LzLalMQih/7PHPZq1KofF8Di63r IjXDDLbB6nUuBFVLaB7BdRhM7OjpgFBu49ZHGwAb980HRL/IGl/BqIW4Yd3RxjD8Mowx Uhk2sZJpbJvWOk4H7U9jkuwJbHtmXtZ0oyVE90wEx+ga2Gx/syMmtQxnlq2NNyVPWS2W 8neMSzGwMhGYxpgvEvFzwS7QNFPYWpU3XjtZ54yNDJoEX1BdH6b20+cHoPWYmdhlJ0lO In1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780854995; x=1781459795; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wrLwqR7E52tys8PCHiVoVNwMCtyGnj9x6DF3Sfvfgds=; b=QgPm8iTwMJCHdLQFtpWnt8MHcu3IJ0/eaLp+XBuzuL5yNz8QK6A3wRcxFncQJlYm2A FJkvw9jiBylHbP1s+KJJFjZ61cz0Y5oKbPpOnyVEjACVhOdROK9ERefxtdPatsM/JqZ/ G+YN2uRF7qbJh2gsaJFVazD+RQ2xObDvbdAMepovFXYuths5evTLDgavFEzD205O41he N6g5ubIzv7n4v+33TrSrGD+uHdOht2Ijs3Nsn8VDuIBLnj0r/d23new8jYJ7V2ufvyVs tOk3JynwrLlTmWIXl68TA+O+86LqZFFFZDNL+saA64FcHvvt442cAnxt6NCgZnSnK7gw 3Dwg== X-Gm-Message-State: AOJu0YzL3xuFkXMCzI/FpHD7FibcmMSbZ3FV1mSC3v3YvH567siGA+0u 5r7X2+uNiEnR0Zwb14Qvi0i4U7/fAndRxvJp7f7lSbcHMl9hlIssY5ngjdTLCZam X-Gm-Gg: Acq92OFkrauq8wBiNKkr3L8UUNTPQZCsz7iV6I7vqyLaZhVIXuYO05qY4RvHJFMHnx9 dmMai+wpjfD+TF3fbZJP3xErIOU2grvVv1wewWWnavD3J4oOztQVHRfF0VP7G8zgRQK+Ai21+Pg KKJXOl/JgusrJRpsb4OZ4mElBwXQx9lvK9O5Akmpt31OfIT0gL5WqIiWgWdFEZMSOudNHEuyk+s 7GEIMkY5FtCD3vcGQshn9YpI9uL+Rjz7QDQlfO8SK0hdjAZX2z7r16x1a2NOQzgbAlJhXeFFq+P H6+8dS4T2J6u9RMbUiqp1s53e41I0VrDIuabKq0RC5LUhxYvp+UbQyXwqaaUsKp5fUHRjUKPRW/ nnRt+GWCtD8Qo9NePbQsl2ZJrHLOi6RJHjiqNTf1InL0wmKTiLoTOGxaKCuGL8VsFqh+lpjRx76 lFsNW3UTmHhJabkUsUHY086WSW2BueRKcdExhIuyQoCxgAgo6Z/+dJsXwGgJl46JtnPojjeCdhP hpsNJwaUA== X-Received: by 2002:a05:600c:45c6:b0:490:b9fe:e64d with SMTP id 5b1f17b1804b1-490c2612b7fmr213764685e9.23.1780854994557; Sun, 07 Jun 2026 10:56:34 -0700 (PDT) Received: from [192.168.0.86] (84.123.230.95.dyn.user.ono.com. [84.123.230.95]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f35eae5sm45626848f8f.33.2026.06.07.10.56.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jun 2026 10:56:34 -0700 (PDT) Message-ID: <89005dba-32f0-414b-9de9-30acbdbdd2f6@gmail.com> Date: Sun, 7 Jun 2026 19:56:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Hashed SAOP on composite type with non-hashable column errors at runtime To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org, Peter Eisentraut References: <3735597.1780683122@sss.pgh.pa.us> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: <3735597.1780683122@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 05/06/2026 20:12, Tom Lane wrote: > So I'm unexcited about putting the fix for this into > convert_saop_to_hashed_saop_walker as you've done here. > I think it needs to be addressed at the level of the relevant > lsyscache.c lookup functions, so that there's some chance that > future code additions will get this right. Draft fix attached. Thanks for your efforts! Now, hash_ok_operator and op_hashjoinable handle all four container-type equality operators. Side way is a C extension that lets you create a custom type that groups other types marked as HASHES. I started this research because I had trouble redesigning my ‘statistics’ type [1], but here, using HASHES seems just not to work for my custom type. Fixes in the lookup_type_cache related to the multirange type are also correct for me. As well as pg_operator.dat changes. > > I can't get excited about the test case you suggest; > it's rather expensive and it will do nothing whatever > to guard against future mistakes of the same kind. Ok, let me think about that a little more. > > I'm also unexcited about your 0002 and 0003. I understand about 0003, but what is the problem with 0002? In practice, people use massive arrays (I’ve seen thousands of elements). You might remember my complaint about planner’s memory consumption on array selectivity estimation a couple of years ago - that time you proposed local planning memory context. So, it’d be nice to see (as with Subplans) whether the SAOP is not hashed for a reason. > I don't really care about optimizing the anonymous-record case; by and large, > it's coincidental that complicated operations work at all on > anonymous record types. Got it. My actual care here is to provide a way (if possible) for extension developers to fix this problem in ORM systems where they can't change the complex application, but have an access pattern and will see regressions, as they struggle with regressions each time after the introduction of a brand-new query tree rewriting rule ;). Note on the ‘lefthashfunc == righthashfunc’ condition. It is correct, because we can compare RECORDs with only identical types in corresponding positions on the left and right side of the comparison operator: if (att1->atttypid != att2->atttypid) ereport(ERROR, "cannot compare dissimilar column types %s and %s ..."); So, if someday typecache is extended to compare, let’s say, (int4, int8) and (int4, numeric), this code should also be revised, right? [1] https://github.com/danolivo/pg_track_optimizer/blob/main/rstats.h -- regards, Andrei Lepikhov, pgEdge