-
Notifications
You must be signed in to change notification settings - Fork 70
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
Timestamp filter pushdown doesn't work in some cases #162
Comments
cc #127 |
Thanks, @Deninc for reporting an issue. The mongo_fdw don't support pushdown of function in WHERE clause. |
Thanks @vaibhavdalvi93. Any plan for support it in the near future? I think filter by date time is such an essential feature. |
Pushing down functions in WHERE has some challenges because MongoDB is a NoSQL database. It is not straightforward to map PostgreSQL functions with the corresponding MongoDB collection operators. Also, it requires too much manual work to map Postgres functions into MongoDB functions/operators. We also need to note that we should be having the same result when pushed down and when not pushed down. Also, result correctness and code maintainability are challenges too. Due to these factors, we have not prioritised it on our roadmap. However, feel free to post a patch in a pull request. We will definitely review it and take it further. |
I agree that pushing down functions to MongoDB is difficult. In the example given above ( Upon further review, this isn't an issue with MongoDB FDW. PostgreSQL will evaluate and simplify any immutable functions with constant arguments. The functions If you want to assume they're immutable, you can create a simple pass-through function that's immutable and calls the function. Then PostgreSQL will simplify the function and it'll work correctly in the FDW. Example function: CREATE OR REPLACE FUNCTION to_timestamp_imm(text, format)
RETURNS TIMESTAMP
AS
$BODY$
select to_timestamp($1, $2);
$BODY$
LANGUAGE sql
IMMUTABLE; Sources: |
When I have this query it does push down:
select count(*) from table where "dateTime" >= '2022-06-07';
But for timestamp query it does not:
select count(*) from table where "dateTime" >= TO_TIMESTAMP('2022-06-07', 'YYYY-MM-DD');
Using:
The text was updated successfully, but these errors were encountered: