>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:
PG> ERROR: ORDER BY position 0 is not in select list
PG> CONTEXT: Remote SQL command: EXPLAIN SELECT relid, schemaname, relname,
PG> seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
PG> n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze,
PG> last_vacuum, last_autovacuum, last_analyze, last_autoanalyze, vacuum_count,
PG> autovacuum_count, analyze_count, autoanalyze_count FROM
PG> pg_catalog.pg_stat_user_tables ORDER BY 0 ASC NULLS LAST
So what's happening here is that there's an equivalence class containing
members "greatest(pg_catalog.pg_stat_user_tables.idx_scan,
public.pg_stat_user_tables.idx_scan)" and "0" (as an integer constant),
and somehow a pathkey for this eclass is becoming attached to the query
going to the remote for statistics purposes.
It seems obviously wrong that a constant pathkey with no actual
reference to the foreign table should be being pushed down, so so far I
suspect that get_useful_pathkeys_for_relation isn't being selective
enough about what is "useful". In this context I find it suspicious that
find_em_expr_for_rel will return an expr with no vars as being "for"
every rel, since it's just looking for a subset.
--
Andrew (irc:RhodiumToad)