-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eligible filters are not pushed down if any are ineligible, resulting in none being pushed down #16339
Comments
In the first version of filter push down: #15653 we only enabled this for safe operators, which is the standard comparison and logical operators, and if anything else is included we don't push down the filter at all. I see 2 improvements here:
|
Splitting on
It is not just about PostgreSQL. JDBC fdw should work for any foreign database that has a JDBC driver. |
Makes sense. The example has been chosen badly in this case. I updated it to better reflect the original issue. We also tried to explicitly split the filters into a cte like ... cr> EXPLAIN WITH foreign_select AS (SELECT * FROM doc.foreign_t01 WHERE c1 = 'Hello')
SELECT * FROM foreign_select WHERE c2['module'] = 'Test%';
+------------------------------------------------------------------------+
| QUERY PLAN |
+------------------------------------------------------------------------+
| Rename[c1, c2] AS foreign_select (rows=0) |
| └ Filter[(('Test%' = c2['module']) AND (c1 = 'Hello'))] (rows=0) |
| └ ForeignCollect[doc.foreign_t01 | [c1, c2] | true] (rows=unknown) |
+------------------------------------------------------------------------+ ... which (un)fortunately gets optimised. With cr> EXPLAIN WITH foreign_select AS (SELECT * FROM doc.foreign_t01 WHERE c1 = 'Hello')
SELECT * FROM foreign_select WHERE c2['module'] = 'Test%';
+----------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------+
| Filter[('Test%' = c2['module'])] (rows=0) |
| └ Rename[c1, c2] AS foreign_select (rows=unknown) |
| └ ForeignCollect[doc.foreign_t01 | [c1, c2] | (c1 = 'Hello')] (rows=unknown) |
+----------------------------------------------------------------------------------+ Deactivating this by default however seems problematic. Within PostgreSQL this most likely could be prevented with the |
CrateDB version
5.7.3
CrateDB setup information
Local 5.7.3
Remote Postgres 16
Problem description
While not strictly defined as supported:
I believe that filters which can be pushed down to the foreign system should be. Currently, if any filter cannot be pushed down, none of the filters are. This means that a simple sub-select or additional filter can turn a very fast query into a very slow one.
Steps to Reproduce
Actual Result
✅ filters are pushed down
❌ filters are not pushed down
Expected Result
🆗 some filters are pushed down
The text was updated successfully, but these errors were encountered: