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

Sec. index: make compound filters utillize sec. indexes #3299

Open
Tracked by #201
islamaliev opened this issue Dec 9, 2024 · 0 comments · May be fixed by #3417
Open
Tracked by #201

Sec. index: make compound filters utillize sec. indexes #3299

islamaliev opened this issue Dec 9, 2024 · 0 comments · May be fixed by #3417
Labels
area/query Related to the query component feature New feature or request perf Performance issue or suggestion

Comments

@islamaliev
Copy link
Contributor

islamaliev commented Dec 9, 2024

at the moment tests like this don't use indexes:

func TestJSONIndex_WithCompoundFilterCondition_ShouldUseIndex(t *testing.T) {
	req := `query {
		User(filter: {_and: [
			{custom: {height: {_eq: 180}}},
			{custom: {weight: {_eq: 80}}}
		]}) {
			name
		}
	}`
	test := testUtils.TestCase{
		Actions: []any{
			testUtils.SchemaUpdate{
				Schema: `
					type User {
						name: String 
						custom: JSON @index
					}`,
			},
			testUtils.CreateDoc{
				Doc: `{
					"name": "John",
					"custom": {"height": 168, "weight": 70}
				}`,
			},
			testUtils.CreateDoc{
				Doc: `{
					"name": "Islam",
					"custom": {"height": 180, "weight": 80}
				}`,
			},
			testUtils.CreateDoc{
				Doc: `{
					"name": "Shahzad",
					"custom": {"height": 180, "weight": 75}
				}`,
			},
			testUtils.CreateDoc{
				Doc: `{
					"name": "Keenan",
					"custom": {"height": 190, "weight": 85}
				}`,
			},
			testUtils.Request{
				Request: req,
				Results: map[string]any{
					"User": []map[string]any{
						{"name": "Islam"},
					},
				},
			},
			testUtils.Request{
				Request:  makeExplainQuery(req),
				Asserter: testUtils.NewExplainAsserter().WithIndexFetches(2),
			},
		},
	}

	testUtils.ExecuteTestCase(t, test)
}

The test uses json, but the behaviour should be the same for other field types.
Most likely majority of the work will be in function findIndexByFilteringField in internal/planner/select.go. But we should add a bunch of tests as well.

@islamaliev islamaliev added feature New feature or request area/query Related to the query component perf Performance issue or suggestion labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component feature New feature or request perf Performance issue or suggestion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant