From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kai Daguerre <kai@turbot.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Custom FDW - the results of a nested query/join not being passed as qual to the outer query
Date: Wed, 27 Jan 2021 10:27:27 -0500
Message-ID: <2391646.1611761247@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFWgLQ+wa8=UCiHKCFs-e4uqkGVV1wZmiTnVxN4jVpwwphmTMw@mail.gmail.com>
References: <CAFWgLQ+wa8=UCiHKCFs-e4uqkGVV1wZmiTnVxN4jVpwwphmTMw@mail.gmail.com>
Kai Daguerre <kai@turbot.com> writes:
> We often have virtual tables where a list operation is not viable/possible
> without providing quals. For example we have implemented a 'whois' table,
> which will retrieve whois information for specified domains. It is clearly
> not practical to do an unqualified 'list' of *all* domains.
In that case you're going to have to resign yourself to some queries
failing. This is unavoidable, consider "select * from whois". But
just because the query has a WHERE condition doesn't mean that a useful
restriction clause can be extracted for any particular table.
I think the best you can do is (1) fail at runtime if there's no qual
and (2) at plan time, return an extremely high cost estimate for a
qual-less scan, in hopes of discouraging the planner from choosing
that. (Instead of (2), you could perhaps not generate a scan path
at all, but that's likely to lead to an unintelligible error message.)
Perhaps you should rethink whether you really want a foreign table
rather than a set-returning function. With the SRF approach it's
automatic that the user must supply the restricting argument(s) you need.
regards, tom lane
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, kai@turbot.com
Subject: Re: Custom FDW - the results of a nested query/join not being passed as qual to the outer query
In-Reply-To: <2391646.1611761247@sss.pgh.pa.us>
References: <CAFWgLQ+wa8=UCiHKCFs-e4uqkGVV1wZmiTnVxN4jVpwwphmTMw@mail.gmail.com> <2391646.1611761247@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