Skip to content
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

Implement pushdown for aggregate for PostgreSQL #3607

Merged
merged 10 commits into from
Oct 23, 2023
Prev Previous commit
Next Next commit
wip
  • Loading branch information
noisersup committed Oct 18, 2023
commit ff6e7e22a023836ba7a3ae638fea3b4efccab2a2
22 changes: 15 additions & 7 deletions internal/handlers/sqlite/msg_explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
return nil, lazyerrors.Error(err)
}

var qp backends.ExplainParams

if params.Aggregate {
qp.Filter, _ = aggregations.GetPushdownQuery(params.StagesDocs)
qp := backends.ExplainParams{
Filter: params.Filter,
}

if h.DisableFilterPushdown {
qp.Filter = nil
sort := params.Sort

if params.Aggregate {
qp.Filter, sort = aggregations.GetPushdownQuery(params.StagesDocs)
chilagrow marked this conversation as resolved.
Show resolved Hide resolved
}

// Skip sorting if there are more than one sort parameters
if h.EnableSortPushdown && params.Sort.Len() == 1 {
if h.EnableSortPushdown && sort.Len() == 1 {
var order types.SortType

k := params.Sort.Keys()[0]
Expand All @@ -107,6 +107,14 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
}
}

if h.DisableFilterPushdown {
qp.Filter = nil
}

if !h.EnableSortPushdown {
qp.Sort = nil
}

res, err := coll.Explain(ctx, &qp)
if err != nil {
return nil, lazyerrors.Error(err)
Expand Down
Loading