Re: Is it expected behavior index only scan shows "OPERATOR(pg_catalog." for EXPLAIN?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Masahiro(dot)Ikeda(at)nttdata(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, Masao(dot)Fujii(at)nttdata(dot)com
Subject: Re: Is it expected behavior index only scan shows "OPERATOR(pg_catalog." for EXPLAIN?
Date: 2024-07-08 12:44:27
Message-ID: 962113.1720442667@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> writes:
> I honestly don't know if this is the correct solution. It seems to me
> handling this at the EXPLAIN level might just mask the issue - it's not
> clear to me why adding "indexqualorig" would remove the ambiguity (if
> there's one). Perhaps it might be better to find why the ruleutils.c
> code thinks the OPERATOR() is necessary, and then improve/fix that?

As Masahiro-san already said, the root cause is that the planner
removes the RelabelType that is on the indexed variable. So ruleutils
sees that the operator is not the one that would be chosen by the
parser given those input expressions (cf generate_operator_name)
and it concludes it'd better schema-qualify the operator. While
that doesn't really make any difference in this particular case,
it is the right thing in typical rule-deparsing cases.

I don't think this output is really wrong, and I'm not in favor
of adding nontrivial overhead to make it better, so I don't like
the proposed patch. Maybe generate_operator_name could use some
other heuristic, but I'm unsure what. The case it wants to cover
is that the operator is in the search path but is masked by some
operator in an earlier schema, so simply testing if the operator's
schema is in the path at all would be insufficient.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2024-07-08 12:45:15 Re: MergeJoin beats HashJoin in the case of multiple hash clauses
Previous Message Laurenz Albe 2024-07-08 12:36:45 Re: Wrong security context for deferred triggers?