Kyotaro HORIGUCHI <horiguchi.kyot...@lab.ntt.co.jp> wrote:

> The patch got conflicted. This is a new version just rebased to
> the current master. Furtuer amendment will be taken later.

Can you please explain this part of make_append() ?

/* Currently async on partitioned tables is not available */
Assert(nasyncplans == 0 || partitioned_rels == NIL);

I don't think the output of Append plan is supposed to be ordered even if the
underlying relation is partitioned. Besides ordering, is there any other
reason not to use the asynchronous execution?

And even if there was some, the planner should ensure that executor does not
fire the assertion statement above. The script attached shows an example how
to cause the assertion failure.

-- 
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at

OPT_HOST="-h localhost"
USER=postgres

for x in $(psql $OPT_HOST -c "SELECT datname FROM pg_database WHERE datname ~ 
'shard.*' " postgres -A -t)

do
        echo dropping $x
        dropdb $OPT_HOST $x
done;

createdb $OPT_HOST shard

psql $OPT_HOST -U $USER shard -c "
        CREATE EXTENSION postgres_fdw;
        CREATE TABLE orders(customer_id int, product_id int)
               PARTITION BY LIST (customer_id);"
createdb $OPT_HOST shard_0
psql $OPT_HOST -U $USER shard_0 -c "
                CREATE TABLE orders_0 AS
                SELECT trunc(2 * random())::int AS customer_id,
                       trunc(100 * random())::int AS product_id
                FROM generate_series(1, 5000);
                ANALYZE;"
psql $OPT_HOST -U $USER shard -c "
                CREATE SERVER server_0 FOREIGN DATA WRAPPER postgres_fdw
                        OPTIONS (host 'localhost', dbname 'shard_0', fetch_size 
'1000',
                        use_remote_estimate 'true', fdw_tuple_cost '10');
                CREATE USER MAPPING FOR CURRENT_USER SERVER server_0 OPTIONS 
(user '$USER');
                IMPORT FOREIGN SCHEMA public FROM SERVER server_0 INTO public;
                ALTER TABLE orders ATTACH PARTITION orders_0 FOR VALUES IN (0, 
1);"

createdb $OPT_HOST shard_1
psql $OPT_HOST -U $USER shard_1 -c "
                CREATE TABLE orders_1 AS
                SELECT trunc(2 * random())::int + 2 AS customer_id,
                       trunc(100 * random())::int + 2 AS product_id
                FROM generate_series(1, 5000);
                ANALYZE;"
psql $OPT_HOST -U $USER shard -c "
                CREATE SERVER server_1 FOREIGN DATA WRAPPER postgres_fdw
                        OPTIONS (host 'localhost', dbname 'shard_1', fetch_size 
'1000',
                        use_remote_estimate 'true', fdw_tuple_cost '10');
                CREATE USER MAPPING FOR CURRENT_USER SERVER server_1 OPTIONS 
(user '$USER');
                IMPORT FOREIGN SCHEMA public FROM SERVER server_1 INTO public;
                ALTER TABLE orders ATTACH PARTITION orders_1 FOR VALUES IN (2, 
3);"


psql $OPT_HOST -U $USER shard -c "SELECT * FROM orders"
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to