Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qZbQl-0066Mn-7D for pgsql-admin@arkaria.postgresql.org; Fri, 25 Aug 2023 18:21:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qZbQj-004qWy-Ue for pgsql-admin@arkaria.postgresql.org; Fri, 25 Aug 2023 18:21:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qZbQj-004qWq-Ir for pgsql-admin@lists.postgresql.org; Fri, 25 Aug 2023 18:21:09 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qZbQc-0011Lb-CC for pgsql-admin@postgresql.org; Fri, 25 Aug 2023 18:21:08 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4fe21e7f3d1so1868747e87.3 for ; Fri, 25 Aug 2023 11:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692987660; x=1693592460; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Ho51PONVBSuIVUnK/ie2fuMo4LkhW9AiffIiZeGfMPA=; b=VzFrIWeVH6ghK/CxO9Th1sPzX6zxgEuB/pMN8C8DC5Pd4jbmULFiD+M6ihEcDao5qL NWPiwIMZ/A/9V1zfrgOID3qCj54PCvF8FUPJNtPdP02pGyRnGYxgjNMWxEznTuPgK2Hq jMIGGVgCQLsDGzTeGBUj72DszuiiVKugg3kSs217sezpoKpktQ5baXGsvmAAcI/QfPTJ axfmfsT/lGTcf0hs1oEglW7MiolKj8Kri+TJdFEcbHX1Iwz6ej3PdB21UBJ6wmTtgsdZ FyMIhQ0+IpnxIAITVmxh53ZpbVdCBHDsDItGXlnhEHSh4d0C+HqrjDbGKNkFF85St7FG 8L2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692987660; x=1693592460; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Ho51PONVBSuIVUnK/ie2fuMo4LkhW9AiffIiZeGfMPA=; b=WONfQ53wcbHKrARdFSy7n4CQfPSlAtacEOAyNc1EWF4AI1ix+krV7PqYJEgVpc/ZBR wp769Tp+LUiPn5A/l+PQ6IxfvOhsrgku/Huj0VE2z3g77wpnVxesL32IcH7oZLbeP9Zt WXVGwV9zEm1T+JhAXO5MeXsFWWECQ+xbBEvCBE8nisrUo0KcOIFZjQqFyaSu25Yt0anE JIPZgIBDODu3a072Cg+Xf0jktdLK2j6Tz3/mBtgtJZRNKAlTXGSJZ2eYb+D9nFx4IujP MrRmkCLqTy+z6jOrC56BqLa4PR7Fd5AJnqplfOcPx2nBS2jQCOA5pTJYxqlCsBBJHZYG lDHg== X-Gm-Message-State: AOJu0Yw0RleVDm3/gkO1vaaQxywpVG5oR1wgOrivdQ7nBJeIEsEQyas+ 0qYqE242QjZLlWjpmVDFXAWVIqXSQazcVHcLS3jOH2dWzqQ= X-Google-Smtp-Source: AGHT+IEFdt8DaNccMr7wES/ldYz6mMBbv67q+qpS5C94JJqGsEzcYXoyUUn469qbk0tTP+g/PAa7X63cKqoEwztKCRI= X-Received: by 2002:a19:5f19:0:b0:4ff:840b:a37b with SMTP id t25-20020a195f19000000b004ff840ba37bmr12269862lfb.14.1692987659523; Fri, 25 Aug 2023 11:20:59 -0700 (PDT) MIME-Version: 1.0 From: Wells Oliver Date: Fri, 25 Aug 2023 11:20:23 -0700 Message-ID: Subject: dblink without running the full query remotely? To: pgsql-admin Content-Type: multipart/alternative; boundary="0000000000000e19e40603c368c4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000e19e40603c368c4 Content-Type: text/plain; charset="UTF-8" Per the documentation -- *dblink fetches the entire remote query result before returning any of it to the local system* -- I am guessing the answer is no, but I wondered if there was some way to do something like this: create view myview as; select * from dblink( 'server', 'select id from sometable') cols(id bigint); And then select * from myview where id = 123; Where that remote sometable might have a bajillion rows and the local where would be passed to it otherwise it's days and days for all rows to be returned and then filtered. -- Wells Oliver wells.oliver@gmail.com --0000000000000e19e40603c368c4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Per the documentation -- dblink fetches the entire remo= te query result before returning any of it to the local system -- I am = guessing the answer is no, but I wondered if there was some way to do somet= hing like this:

crea= te view myview as;
select * from dblink(
=C2=A0 =C2=A0 'server= 9;,
=C2=A0 =C2=A0 'select id from sometable')
cols(id bigint)= ;


And then

select * from myview where id =3D 123;

Where that remote sometable might have a bajillion rows and the loca= l where would be passed to it otherwise it's days and days for all rows= to be returned and then filtered.

--
Wells Oliver
wells.oliver@gmail= .com
--0000000000000e19e40603c368c4--