pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ying Lu <emi.lu@concordia.ca>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: psql12.3 + jdbc_fdw - return wrong query results by using OR
Date: Thu, 28 May 2020 14:39:56 -0400
Message-ID: <7464.1590691196@sss.pgh.pa.us> (raw)
In-Reply-To: <1590686553201.26345@concordia.ca>
References: <20200528113956.767qptz1cg44cw0g@webmail.encs.concordia.ca>
	<625d4581-6b92-6368-f1a2-eedf4f6c890a@aklaver.com>
	<1590685166535.433@concordia.ca>
	<f25c1795-6a7c-ff3a-888c-037ccb694f4c@aklaver.com>
	<1590686553201.26345@concordia.ca>

Ying Lu <emi.lu@concordia.ca> writes:
> For Q1: 

>                                                           QUERY PLAN
> -------------------------------------------------------------------------------------------------------------------------------
>  Aggregate  (cost=5.40..5.41 rows=1 width=8) (actual time=1267.001..1267.001 rows=1 loops=1)
>    ->  Hash Join  (cost=2.10..4.78 rows=245 width=0) (actual time=0.134..1265.840 rows=2650 loops=1)
>          Hash Cond: (a.c1 = b.c1)
>          ->  Foreign Scan on oracle_t1 a  (cost=0.00..0.00 rows=1000 width=32) (actual time=0.026..1257.823 rows=14625 loops=1)
>          ->  Hash  (cost=1.49..1.49 rows=49 width=5) (actual time=0.030..0.030 rows=49 loops=1)
>                Buckets: 1024  Batches: 1  Memory Usage: 10kB
>                ->  Seq Scan on local_t1 b  (cost=0.00..1.49 rows=49 width=5) (actual time=0.014..0.021 rows=49 loops=1)
>  Planning Time: 0.178 ms
>  Execution Time: 1363.482 ms

> For Q2: 

>      QUERY PLAN
> ----------------------------------------------------------------------------------------------------------------------------
>  Aggregate  (cost=737.71..737.72 rows=1 width=8) (actual time=1197.366..1197.366 rows=1 loops=1)
>    ->  Nested Loop  (cost=0.00..736.49 rows=489 width=0) (actual time=16.649..1197.292 rows=70 loops=1)
>          Join Filter: ((a.c1 = b.c1) OR (a.c2 = b.c1))
>          Rows Removed by Join Filter: 14555
>          ->  Seq Scan on local_t1 b  (cost=0.00..1.49 rows=49 width=5) (actual time=0.016..0.023 rows=49 loops=1)
>          ->  Foreign Scan on oracle_t1 a  (cost=0.00..0.00 rows=1000 width=64) (actual time=0.002..24.284 rows=298 loops=49)
>  Planning Time: 0.972 ms
>  Execution Time: 1299.896 ms

The numbers here are consistent with the theory that there are 14625 rows
in the foreign table, but when oracle_t1 is scanned on the inside of a
nest loop, the FDW returns all of them on the first scan and then forgets
to return any when rescanned.  This'd be a bug in jdbc_fdw, and a
pretty bad one :-(.  But you'd have to report it to the jdbc_fdw
author(s) --- the core Postgres project doesn't maintain that.

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <7464.1590691196@sss.pgh.pa.us>
Permalink:  ../7464.1590691196@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7464.1590691196@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, emi.lu@concordia.ca, adrian.klaver@aklaver.com
  Subject: Re: psql12.3 + jdbc_fdw - return wrong query results by using OR
  In-Reply-To: <7464.1590691196@sss.pgh.pa.us>
  References: <20200528113956.767qptz1cg44cw0g@webmail.encs.concordia.ca> <625d4581-6b92-6368-f1a2-eedf4f6c890a@aklaver.com> <1590685166535.433@concordia.ca> <f25c1795-6a7c-ff3a-888c-037ccb694f4c@aklaver.com> <1590686553201.26345@concordia.ca> <7464.1590691196@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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