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

Pushdown simplest sorting for aggregate command #2530

Merged
merged 26 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
noisersup committed Apr 26, 2023
commit 00d97d972001983e5cac50564fe8082efe07a1b2
14 changes: 14 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,20 @@ tasks:
--postgresql-url=postgres://username@127.0.0.1:5432/ferretdb
--test-records-dir=tmp/records

run-sort:
desc: "Run FerretDB with `pg` handler"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}} -test.coverprofile=cover.txt --
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=pg
--postgresql-url=postgres://username@127.0.0.1:5432/ferretdb
--test-records-dir=tmp/records
--test-enable-sorting-pushdown

run-tigris:
desc: "Run FerretDB with `tigris` handler"
deps: [build-host]
Expand Down
2 changes: 2 additions & 0 deletions cmd/ferretdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var cli struct {
Test struct {
RecordsDir string `default:"" help:"Experimental: directory for record files."`
DisableFilterPushdown bool `default:"false" help:"Experimental: disable filter pushdown."`
EnableSortingPushdown bool `default:"false" help:"Experimental: enable sorting pushdown."`
EnableCursors bool `default:"false" help:"Experimental: enable cursors."`

//nolint:lll // for readability
Expand Down Expand Up @@ -339,6 +340,7 @@ func run() {

TestOpts: registry.TestOpts{
DisableFilterPushdown: cli.Test.DisableFilterPushdown,
NativeSort: cli.Test.EnableSortingPushdown,
EnableCursors: cli.Test.EnableCursors,
},
})
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,

qp.Explain = true

qp.NativeSort = true
qp.NativeSort = h.NativeSort

explain, err := common.GetRequiredParam[*types.Document](document, "explain")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er
DB: params.DB,
Collection: params.Collection,
Comment: params.Comment,
NativeSort: true,
NativeSort: h.NativeSort,
}

// get comment from query, e.g. db.collection.find({$comment: "test"})
Expand Down
1 change: 1 addition & 0 deletions internal/handlers/pg/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type NewOpts struct {

// test options
DisableFilterPushdown bool
NativeSort bool
EnableCursors bool
}

Expand Down
2 changes: 2 additions & 0 deletions internal/handlers/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type NewHandlerOpts struct {
// TestOpts represents experimental configuration options.
type TestOpts struct {
DisableFilterPushdown bool
NativeSort bool
EnableCursors bool
}

Expand Down Expand Up @@ -101,6 +102,7 @@ func init() {
StateProvider: opts.StateProvider,

DisableFilterPushdown: opts.DisableFilterPushdown,
NativeSort: opts.NativeSort,
EnableCursors: opts.EnableCursors,
}
return pg.New(handlerOpts)
Expand Down