Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pP3W2-00082p-BJ for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Feb 2023 15:34:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pP3W0-0004Cm-5P for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Feb 2023 15:34:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pP3Vz-0004By-Ru for pgsql-bugs@lists.postgresql.org; Mon, 06 Feb 2023 15:34:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pP3Vx-0007DT-Fx for pgsql-bugs@postgresql.org; Mon, 06 Feb 2023 15:34:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 316FYOLn2665267; Mon, 6 Feb 2023 10:34:26 -0500 From: Tom Lane To: "Qu, Mischa, Majorel China" cc: "pgsql-bugs@postgresql.org" Subject: Re: exceptional result of postres_fdw external table joining local table In-reply-to: References: Comments: In-reply-to "Qu, Mischa, Majorel China" message dated "Mon, 06 Feb 2023 10:30:31 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2665265.1675697664.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 06 Feb 2023 10:34:24 -0500 Message-ID: <2665266.1675697664@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Qu, Mischa, Majorel China" writes: > But when I run some full table scans and found a problems. the results o= f 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=3Dt6.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