Hi All, Explain [Analyze] Select Into table..... produces the plan which uses parallel scans.
*Test:*
create table table1 (n int);
insert into table1 values (generate_series(1,5000000));
analyze table1;
set parallel_tuple_cost=0;
set max_parallel_degree=3;
postgres=# explain select into table2 from table1;
QUERY PLAN
-------------------------------------------------------------------------------
Gather (cost=1000.00..39253.03 rows=5000000 width=0)
Number of Workers: 3
-> Parallel Seq Scan on table1 (cost=0.00..38253.03 rows=1612903
width=0)
(3 rows)
-----------------------------
*So Explain Analyze Fails.*
postgres=# explain analyze select into table2 from table1;
ERROR: cannot insert tuples during a parallel operation
STATEMENT: explain analyze select into table2 from table1;
*But actual execution is successful.*
postgres=# select into table2 from table1;
SELECT 5000000
Reason is in ExplainOneQuery we unconditionally
pass CURSOR_OPT_PARALLEL_OK to pg_plan_query even if query might be from
CreateTableAs/ SelectInto. Whereas in *ExecCreateTableAs *it is always 0*.*
*Possible Fix:*
I tried to make a patch to fix this. Now in ExplainOneQuery if into clause
is
defined then parallel plans are disabled as similar to their execution.
--
Thanks and Regards
Mithun C Y
EnterpriseDB: http://www.enterprisedb.com
Analyze_select_into_disable_parallel_scan.patch
Description: Binary data
-- Sent via pgsql-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
