我正在从本地客户端对远程 Postgres 实例运行以下查询:
select * from matches_tb1 order by match_id desc limit 10;
matches_tb1
是一个外部表,具有match_id
唯一索引。查询似乎永远挂起。当我使用explain verbose
时,没有ORDER BY
附加到“远程 SQL”。我猜本地服务器没有将订单下推到远程服务器。我该如何解决这个问题?
附上解释结果:
explain verbose select match_id from matches_tb1 order by match_id desc limit 10;
QUERY PLAN
---------------------------------------------------------------------------------------------------
Limit (cost=33972852.96..33972852.98 rows=10 width=8)
Output: match_id
-> Sort (cost=33972852.96..35261659.79 rows=515522734 width=8)
Output: match_id
Sort Key: matches_tb1.match_id DESC
-> Foreign Scan on public.matches_tb1 (cost=100.00..22832592.02 rows=515522734 width=8)
Output: match_id
Remote SQL: SELECT match_id FROM public.matches_tb1
(8 rows)