mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Fix EXPLAIN ANALYZE for async-capable nodes.
EXPLAIN ANALYZE for an async-capable ForeignScan node associated with
postgres_fdw is done just by using instrumentation for ExecProcNode()
called from the node's callbacks, causing the following problems:
1) If the remote table to scan is empty, the node is incorrectly
considered as "never executed" by the command even if the node is
executed, as ExecProcNode() isn't called from the node's callbacks at
all in that case.
2) The command fails to collect timings for things other than
ExecProcNode() done in the node, such as creating a cursor for the
node's remote query.
To fix these problems, add instrumentation for async-capable nodes, and
modify postgres_fdw accordingly.
My oversight in commit 27e1f1456
.
While at it, update a comment for the AsyncRequest struct in execnodes.h
and the documentation for the ForeignAsyncRequest API in fdwhandler.sgml
to match the code in ExecAsyncAppendResponse() in nodeAppend.c, and fix
typos in comments in nodeAppend.c.
Per report from Andrey Lepikhov, though I didn't use his patch.
Reviewed-by: Andrey Lepikhov
Discussion: https://postgr.es/m/2eb662bb-105d-fc20-7412-2f027cc3ca72%40postgrespro.ru
This commit is contained in:
@ -10051,6 +10051,21 @@ SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1;
|
||||
Filter: (t1_3.b === 505)
|
||||
(14 rows)
|
||||
|
||||
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
|
||||
SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1;
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Limit (actual rows=1 loops=1)
|
||||
-> Append (actual rows=1 loops=1)
|
||||
-> Async Foreign Scan on async_p1 t1_1 (actual rows=0 loops=1)
|
||||
Filter: (b === 505)
|
||||
-> Async Foreign Scan on async_p2 t1_2 (actual rows=0 loops=1)
|
||||
Filter: (b === 505)
|
||||
-> Seq Scan on async_p3 t1_3 (actual rows=1 loops=1)
|
||||
Filter: (b === 505)
|
||||
Rows Removed by Filter: 101
|
||||
(9 rows)
|
||||
|
||||
SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1;
|
||||
a | b | c
|
||||
------+-----+------
|
||||
@ -10132,18 +10147,32 @@ SELECT * FROM join_tbl ORDER BY a1;
|
||||
(3 rows)
|
||||
|
||||
DELETE FROM join_tbl;
|
||||
RESET enable_mergejoin;
|
||||
RESET enable_hashjoin;
|
||||
-- Clean up
|
||||
DROP TABLE async_pt;
|
||||
DROP TABLE base_tbl1;
|
||||
DROP TABLE base_tbl2;
|
||||
DROP TABLE result_tbl;
|
||||
DROP TABLE local_tbl;
|
||||
DROP FOREIGN TABLE remote_tbl;
|
||||
DROP FOREIGN TABLE insert_tbl;
|
||||
DROP TABLE base_tbl3;
|
||||
DROP TABLE base_tbl4;
|
||||
RESET enable_mergejoin;
|
||||
RESET enable_hashjoin;
|
||||
-- Check EXPLAIN ANALYZE for a query that scans empty partitions asynchronously
|
||||
DELETE FROM async_p1;
|
||||
DELETE FROM async_p2;
|
||||
DELETE FROM async_p3;
|
||||
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
|
||||
SELECT * FROM async_pt;
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Append (actual rows=0 loops=1)
|
||||
-> Async Foreign Scan on async_p1 async_pt_1 (actual rows=0 loops=1)
|
||||
-> Async Foreign Scan on async_p2 async_pt_2 (actual rows=0 loops=1)
|
||||
-> Seq Scan on async_p3 async_pt_3 (actual rows=0 loops=1)
|
||||
(4 rows)
|
||||
|
||||
-- Clean up
|
||||
DROP TABLE async_pt;
|
||||
DROP TABLE base_tbl1;
|
||||
DROP TABLE base_tbl2;
|
||||
DROP TABLE result_tbl;
|
||||
DROP TABLE join_tbl;
|
||||
ALTER SERVER loopback OPTIONS (DROP async_capable);
|
||||
ALTER SERVER loopback2 OPTIONS (DROP async_capable);
|
||||
|
Reference in New Issue
Block a user