Skip to content

Commit

Permalink
Push down joins to the remote MongoDB servers.
Browse files Browse the repository at this point in the history
If we have a join between two foreign tables from the same remote
server, push that join down to the remote server instead of fetching
all the rows for both the tables and performing a join locally.  This
will have a very significant win in many practical cases.

Since it is very unclear that which of the operators are supported on
the MongoDB servers, currently join involving only relational and
arithmetic operators in join-clauses are pushed down to avoid any
potential join failure.  Also, only INNER and LEFT/RIGHT OUTER
joins are supported, and not FULL, SEMI, and ANTI joins.  Moreover,
only joins between two tables are pushed down and not when either
inner or outer relation is the join itself.

We use an aggregate pipeline with the lookup operator.  Also, the
MongoDB server returns join results as an array, and thus to get in
a tuple form we use the unwind operator.

This patch also supports the partition-wise join push-down when the
table is partitioned.

FDW-138, Vaibhav Dalvi, reviewed by Suraj Kharage and Jeevan Chalke,
with additional improvements by me. Tested by Rajkumar Raghuwanshi.
  • Loading branch information
jeevanchalke committed Nov 15, 2021
1 parent 2f6c2bc commit 198753b
Show file tree
Hide file tree
Showing 7 changed files with 2,084 additions and 179 deletions.
2 changes: 1 addition & 1 deletion Makefile.meta
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MONGO_INCLUDE = $(shell pkg-config --cflags libmongoc-1.0)
PG_CPPFLAGS = --std=c99 $(MONGO_INCLUDE) -I$(LIBJSON) -DMETA_DRIVER
SHLIB_LINK = $(shell pkg-config --libs libmongoc-1.0)

OBJS = connection.o option.o mongo_wrapper_meta.o mongo_fdw.o mongo_query.o $(LIBJSON_OBJS)
OBJS = connection.o option.o mongo_wrapper_meta.o mongo_fdw.o mongo_query.o deparse.o $(LIBJSON_OBJS)


EXTENSION = mongo_fdw
Expand Down
Loading

0 comments on commit 198753b

Please sign in to comment.