Unnecessary calculations in Execproject

From: 赵庭海(庭章) <zhaotinghai(dot)zth(at)alibaba-inc(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Unnecessary calculations in Execproject
Date: 2025-09-19 07:40:07
Message-ID: c6243658-5446-464a-bd1c-4a4ab850eca1.zhaotinghai.zth@alibaba-inc.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,
I'm recently working on debugging an extension that utilizes user-defined operator
classes, and I find it hard to understand some of the details.

I'll use extension cube as an example to briefly describe my problem, execute
following sql,

```
CREATE EXTENSION cube;
CREATE TABLE test(a int,b cube);
CREATE INDEX ON test USING gist(b);
INSERT INTO test VALUES (1, '[(1), (2)]');
SET enable_seqscan TO off;
SELECT a FROM test ORDER BY b~>1;
```

In this case, the tuple returned by indexscan has been ordered according to the
expression b~>1, but this expression is still executed in Execproject.

I hacked some of the code into my extension to skip these unnecessary operations,
and the performance will improve by 2%~5%. Then I think that if there is a way
to remove the nodes corresponding to these redundant operations in the targetlist
when initializing the execute node, this performance optimization will be applicable
widely. If this idea can be approved, I can try to write a patch for it.

Warm regards,
Zhao.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-09-19 08:07:48 RE: Introduce XID age based replication slot invalidation
Previous Message Daniel Gustafsson 2025-09-19 07:39:08 Re: encode/decode support for base64url