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 1oAvJ3-0006vh-6T for pgsql-performance@arkaria.postgresql.org; Mon, 11 Jul 2022 15:26:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oAvJ2-0000UC-2A for pgsql-performance@arkaria.postgresql.org; Mon, 11 Jul 2022 15:26:40 +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 1oAvJ1-0000Pn-LA for pgsql-performance@lists.postgresql.org; Mon, 11 Jul 2022 15:26:39 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oAvIw-0008BQ-L3 for pgsql-performance@lists.postgresql.org; Mon, 11 Jul 2022 15:26:38 +0000 Received: by mail-wr1-x429.google.com with SMTP id v14so7489305wra.5 for ; Mon, 11 Jul 2022 08:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=SDckBDRa5VOPzT8lLfqk4CuB1rLBx5hxTeyaIt5X9OA=; b=L20L9NTq4SkdT4k9WXBB07SkOFVWI3oMWXGJtFoUVBe1m0q0IT04S9JG4w6rbXVdho hzvWqk1yGmQP0lKxEqeKchh0E53Q6TQnbKU9SYNcPraESqSzFHpRgYyVrx6GKjtG4LKD B/qgQ9UYeqBDDpdIWYKfbueIHRofnRwA+SBCrA3/2gwlxC4Gn9rBR8svMFklGQXQwENt pkSTazM+KWLwaYScGN7A5nTeDS9Q7kaSKh7MKB5oNG+lBBzZ6MNkkztLHnl1uCi7nfU3 4lyXpwmef1U5bUHmt7zKzCI5o0Fw+2SLfmIsZeoh8yM2u+sHlcWdcSt5rRwJSgCHbc9M oBZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=SDckBDRa5VOPzT8lLfqk4CuB1rLBx5hxTeyaIt5X9OA=; b=zy1ux4/HPL+qJxRlazT6TJ79ru83ZFDLsqKfw+BQH1W7xeGCOAIUwmdnNADmJH39NZ 9rGM0pjFD6pV7u+x1ZkTfusFKFgFFdRSD+Mod2xZE5N79vfSR2CgH0KUujGlZ2Ixm7Md 45ma6cQ5YavG7oP/rL1HhTBTYl0LKNcbAN9AvzK61F/KU7zfFXCfmUk30n7yy9MZZOEC fFr017Zktfd9IbzunXK9BH5o1bSSbSUObNWaRYYoAOttmmxaaJXYDZLfEa0k2ZyfogNR 2n3U56U6JLE88jrUWfoDgJff3afFIGzACq00QDcSjjWHdWlC005DwWgTAEtbCsLYohxq +PvA== X-Gm-Message-State: AJIora/2nWxkxyi58BMWXOLsMvIcxBWuMAJClSVEitTWaxz8lFGlWLKn 96CtZNMiWb9Qz7e56Pz0Isk+9A== X-Google-Smtp-Source: AGRyM1s7ThR5D57zk8VqYqniCCF8U2NhE8Z7TwPMUuGi2NQuEWGkzs6nvR3c/lXu1HEsfhXAcpMcVw== X-Received: by 2002:a5d:4a0f:0:b0:21d:9a5e:6b47 with SMTP id m15-20020a5d4a0f000000b0021d9a5e6b47mr11067525wrq.213.1657553191995; Mon, 11 Jul 2022 08:26:31 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:6981:5661:3705:96e2:4650]) by smtp.gmail.com with ESMTPSA id l16-20020a056000023000b0020fff0ea0a3sm5956098wrz.116.2022.07.11.08.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:26:31 -0700 (PDT) Message-ID: <2167710abc29807eb5ba56e0ac8f3f23dad337a9.camel@cybertec.at> Subject: Re: Oracle_FDW table performance issue From: Laurenz Albe To: aditya desai , Pgsql Performance Date: Mon, 11 Jul 2022 17:26:30 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2022-07-11 at 17:38 +0530, aditya desai wrote: > I have one Oracle fdw table which is giving performance issue when joined > local temp table gives performance issue. > > select * from oracle_fdw_table where transaction_id in ( select transaction_id from temp_table) > ---- 54 seconds. Seeing HASH SEMI JOIN  in EXPLAIN PLAN. temp_table has only 74 records. > > select * from from oracle_fdw_table where transaction_id in ( 1,2,3,.....,75)--- 23ms. > > Could you please help me understand this drastic behaviour change? The first query joins a local table with a remote Oracle table. The only way for such a join to avoid fetching the whole Oracle table would be to have the foreign scan on the inner side of a nested loop join. But that would incur many round trips to Oracle and is therefore perhaps not a great plan either. In the second case, the whole IN list is shipped to the remote side. In short, the queries are quite different, and I don't think it is possible to get the first query to perform as well as the second. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com