mongo_fdw icon indicating copy to clipboard operation
mongo_fdw copied to clipboard

No WHERE pushdown for ObjectID (NAME) based queries.

Open Climax777 opened this issue 7 months ago • 5 comments

Closed issue #163 implies we cannot get WHERE clause pushdown on ObjectID (NAME) types queries.

For example, in the provided example in https://www.enterprisedb.com/docs/mongo_data_adapter/latest/08c_example_where_pushdown/ querying for a specific one causes a collection scan (this is an objectID generated in the insert): select * from emp where _id = '654ca5772cff3e18f66ce383'

Resulting explain analyze:

"QUERY PLAN"
"Foreign Scan on public.emp (actual time=4.406..4.416 rows=1 loops=1)"
"  Output: eid"
"  Filter: (emp._id = '654ca5772cff3e18f66ce383'::name)"
"  Rows Removed by Filter: 3"
"  Foreign Namespace: edb.emp"
"Planning Time: 0.103 ms"
"Execution Time: 5.383 ms"

Note 3 rows were returned from the foreign end, which means the OID query hasn't been pushed down. This, to me, is a big problem since there are many common scenarios where this is required to be filtered at the foreign end.

Climax777 avatar Nov 10 '23 06:11 Climax777