Re: Non-trivial condition is only propagated to one side of JOIN

2024-08-26 Thread Wetmore, Matthew (CTR)
You must use a where clause on the FDW table or you get a full load/SEQ scan of that table, per documentation. Select * is not recommended for FDW tables. From: Tobias Hoffmann Date: Sunday, August 25, 2024 at 8:10 AM To: "pgsql-hack...@postgresql.org" Subject: Non-trivial condition is only pr

Re: Non-trivial condition is only propagated to one side of JOIN

2024-08-26 Thread Tobias Hoffmann
On 25/08/2024 19:28, Tom Lane wrote: For this particular case, you could probably get somewhere by writing SELECT * FROM view1 WHERE site_id = 1 UNION ALL SELECT * FROM view1 WHERE site_id IS NULL; Thank you for your suggestion, Tom. Unfortunately, as I now understand, nothing *except*  `var

Re: Non-trivial condition is only propagated to one side of JOIN

2024-08-25 Thread Tom Lane
Tobias Hoffmann writes: > A more complete example might look more like this: > CREATE VIEW "subview1" AS >   SELECT tbl1.site_id, ... JOIN ... ON tbl1.site_id = tbl2.site_id > WHERE ...; > CREATE VIEW "view1" AS >   SELECT site_id, ... FROM subview1  -- maybe even: WHERE site_id IS > NOT NUL

Re: Non-trivial condition is only propagated to one side of JOIN

2024-08-25 Thread Tobias Hoffmann
On 25/08/2024 17:35, David G. Johnston wrote: On Sunday, August 25, 2024, Tobias Hoffmann wrote: 3) Problematic example: # EXPLAIN SELECT * FROM tbl1 JOIN tbl2 ON tbl2.site_id = tbl1.site_id WHERE tbl1.site_id = 1 OR tbl1.site_id IS NULL; The “is null” predicate in this query

Re: Non-trivial condition is only propagated to one side of JOIN

2024-08-25 Thread Tom Lane
"David G. Johnston" writes: > On Sunday, August 25, 2024, Tobias Hoffmann > wrote: >> 3) Problematic example: >> >> # EXPLAIN SELECT * FROM tbl1 JOIN tbl2 ON tbl2.site_id = tbl1.site_id >> WHERE tbl1.site_id = 1 OR tbl1.site_id IS NULL; > The “is null” predicate in this query is doing nothing a

Re: Non-trivial condition is only propagated to one side of JOIN

2024-08-25 Thread David G. Johnston
On Sunday, August 25, 2024, Tobias Hoffmann wrote: > > 3) Problematic example: > > # EXPLAIN SELECT * FROM tbl1 JOIN tbl2 ON tbl2.site_id = tbl1.site_id > WHERE tbl1.site_id = 1 OR tbl1.site_id IS NULL; The “is null” predicate in this query is doing nothing as your next comment alludes to; you