[BUGS] BUG #14505: explain verbose for postgresql_fdw - Mailing list pgsql-bugs

From jeff.janes@gmail.com
Subject [BUGS] BUG #14505: explain verbose for postgresql_fdw
Date
Msg-id 20170118234359.1430.69705@wrigleys.postgresql.org
Whole thread Raw
Responses Re: [BUGS] BUG #14505: explain verbose for postgresql_fdw  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      14505
Logged by:          Jeff Janes
Email address:      jeff.janes@gmail.com
PostgreSQL version: 9.6.1
Operating system:   Linux (CentOS)
Description:

The "Output:" line of explain verbose lists columns of foreign table that
are not actually output, or at least ought not be output.  This extends back
to at least 9.4 as well

explain verbose select local12,a3 from local1 join remote4 on (foobar=a7);

                       QUERY PLAN
-------------------------------------------------------------------------
 Hash Join  (cost=121.25..242.85 rows=2325 width=70)
   Output: local1.local12, remote4.a3
   Hash Cond: (remote4.a7 = local1.foobar)
   ->  Foreign Scan on public.remote4  (cost=100.00..137.90 rows=930
width=64)
         Output: remote4.id, remote4.code, remote4.a1, remote4.a2,
remote4.a3, remote4.a4, remote4.a5, remote4.a6, remote4.a7, remote4.a8,
remote4.a9
         Remote SQL: SELECT a3, a7 FROM remote.remote4
   ->  Hash  (cost=15.00..15.00 rows=500 width=70)
         Output: local1.local12, local1.foobar
         ->  Seq Scan on public.local1  (cost=0.00..15.00 rows=500
width=70)
               Output: local1.local12, local1.foobar


If the remote SQL only selects a3 and a7, how can all columns be output?

Full reproduction:


drop database foobar;
create database foobar;
\c foobar

CREATE EXTENSION IF NOT EXISTS postgres_fdw WITH SCHEMA public;

CREATE SERVER remote_server FOREIGN DATA WRAPPER postgres_fdw options
(dbname 'foobar') ;
CREATE USER MAPPING FOR postgres SERVER remote_server OPTIONS (
    "user" 'postgres'
);

CREATE TABLE local1 (
    local12 character varying(40) NOT NULL,
    foobar text,
    local13 text,
    local19 text
);

CREATE schema remote;

CREATE TABLE remote.remote4 (
    id bigint NOT NULL,
    code character varying(255) NOT NULL,
    a1 text,
    a2 text,
    a3 text,
    a4 text,
    a5 text,
    a6 text,
    a7 text,
    a8 text,
    a9 text
);

CREATE FOREIGN TABLE remote4 (
    id bigint NOT NULL,
    code character varying(255) NOT NULL,
    a1 text,
    a2 text,
    a3 text,
    a4 text,
    a5 text,
    a6 text,
    a7 text,
    a8 text,
    a9 text
)
SERVER remote_server
OPTIONS (
    schema_name 'remote',
    table_name 'remote4'
);

explain verbose select local12,a3 from local1 join remote4 on (foobar=a7);

-- doesn't happen on local table

explain verbose select local12,a3 from local1 join remote.remote4 on
(foobar=a7);



--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [BUGS] BUG #14446: make_date with negative year
Next
From: Clailson
Date:
Subject: [BUGS] Optimization inner join