From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Chris Cleveland <ccleveland(at)dieselpoint(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Index access method not receiving an orderbys ScanKey |
Date: | 2024-04-26 00:14:13 |
Message-ID: | 4030683.1714090453@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Chris Cleveland <ccleveland(at)dieselpoint(dot)com> writes:
> Can anyone tell me why my index access method isn't seeing an order_by
> ScanKey when there is a query with an ORDER BY clause that uses an operator
> that the access method supports?
Hmm, you have
> CREATE OPERATOR pg_catalog.<<=>> (
> FUNCTION = rdb.test_sort_match,
> LEFTARG = record,
> RIGHTARG = rdb.TestSort
> );
> CREATE OPERATOR CLASS rdb_ops DEFAULT FOR TYPE record USING rdb AS
> OPERATOR 1 pg_catalog.<===> (record, rdb.userqueryspec),
> OPERATOR 2 pg_catalog.<<=>> (record, rdb.testsort) FOR ORDER BY
> pg_catalog.float_ops;
> sql = "CREATE FUNCTION rdb.test_sort_match(rec record, testsort
> rdb.TestSort) RETURNS bool IMMUTABLE STRICT PARALLEL SAFE LANGUAGE c AS
> 'MODULE_PATHNAME', 'dummysort_match_wrapper';",
> requires = [DummySortSpec]
So <<=>> returns a bool, not anything that float_ops would apply to.
You might think that that should result in an error, but not
per this comment in opclasscmds.c:
* Ordering op, check index supports that. (We could perhaps also
* check that the operator returns a type supported by the sortfamily,
* but that seems more trouble than it's worth here. If it does not,
* the operator will never be matchable to any ORDER BY clause, but no
* worse consequences can ensue. Also, trying to check that would
* create an ordering hazard during dump/reload: it's possible that
* the family has been created but not yet populated with the required
* operators.)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-04-26 02:20:47 | Re: pgsql: psql: add an optional execution-count limit to \watch. |
Previous Message | Robert Haas | 2024-04-26 00:01:46 | Re: New GUC autovacuum_max_threshold ? |