pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedexceptional result of postres_fdw external table joining local table
2+ messages / 2 participants
[nested] [flat]
* exceptional result of postres_fdw external table joining local table
@ 2023-02-06 10:30 Qu, Mischa, Majorel China <mischa.qu@majorel.cn>
0 siblings, 1 reply; 2+ messages in thread
From: Qu, Mischa, Majorel China @ 2023-02-06 10:30 UTC (permalink / raw)
To: pgsql-bugs
Hi,
I found a problem when using postres_fdw external table.
The PGDB version is 11.9。 I created a postgres_fdw external table to use a table from another DB, and I added use_remote_estimate true option to optimize remote sql。
gap_new=> \des+
List of foreign servers
Name | Owner | Foreign-data wrapper | Access privileges | Type | Version | FDW options | Descri
ption
----------------+-------+----------------------+-------------------+------+---------+------------------------------------------------------------------------------------+---
server28wx_fdw | gap | postgres_fdw | qu=U/qu | | | (host '192.168.1.28', port '5432', dbname 'db1', use_remote_estimate 'true') |
(1 row)
But when I run some full table scans and found a problems. the results of the following sql were different.
Method 1: directly join external table and local table
select count(distinct user_id),count(distinct member_code)
from a_fdw t1
join b as t6 on t1.user_id=t6.tags ->> '10'::varchar(50)
where coalesce(user_id,'') <> '';
-- result: 50739 50845
Method 2: create a local temp table from external table and then join temp table and local table.
drop table if exists temp_a;
select *
into temp temp_a
from a_fdw;
select count(distinct user_id),count(distinct member_code)
from a_fdw t1
join b as t6 on t1.user_id=t6.tags ->> '10'::varchar(50)
where coalesce(user_id,'') <> '';
--result 1641737 1645368
The two methods produces different results. And apparently, the result of Method 1 lost some data.
Is there some problem with use_remote_estimate option configuration ?
CAUTION: This e-mail and any attachments may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is forbidden. Please consider the environment before printing this e-mail!.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: exceptional result of postres_fdw external table joining local table
@ 2023-02-06 15:34 Tom Lane <tgl@sss.pgh.pa.us>
parent: Qu, Mischa, Majorel China <mischa.qu@majorel.cn>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2023-02-06 15:34 UTC (permalink / raw)
To: Qu, Mischa, Majorel China <mischa.qu@majorel.cn>; +Cc: pgsql-bugs
"Qu, Mischa, Majorel China" <mischa.qu@majorel.cn> writes:
> But when I run some full table scans and found a problems. the results of the following sql were different.
> Method 1: directly join external table and local table
> select count(distinct user_id),count(distinct member_code)
> from a_fdw t1
> join b as t6 on t1.user_id=t6.tags ->> '10'::varchar(50)
> where coalesce(user_id,'') <> '';
> -- result: 50739 50845
What sort of plan is that query using? If it's a merge join, I'd
bet that the problem is related to local and remote servers not
having the same default collation.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-02-06 15:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 10:30 exceptional result of postres_fdw external table joining local table Qu, Mischa, Majorel China <mischa.qu@majorel.cn>
2023-02-06 15:34 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox