Skip to content

Commit 03e7ed4

Browse files
Google APIscopybara-github
authored andcommitted
feat: add new types QueryMode, QueryPlan, ResultSetStats
feat: add QueryMode field to RunQueryRequest feat: add ResultSetStats field to RunQueryResponse feat: add QueryMode field to RunAggregationQueryRequest feat: add ResultSetStats field to RunAggregationQueryResponse PiperOrigin-RevId: 595774772
1 parent 6585871 commit 03e7ed4

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

google/datastore/v1/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ proto_library(
2525
"datastore.proto",
2626
"entity.proto",
2727
"query.proto",
28+
"query_profile.proto",
2829
],
2930
deps = [
3031
"//google/api:annotations_proto",

google/datastore/v1/datastore.proto

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import "google/api/routing.proto";
2323
import "google/datastore/v1/aggregation_result.proto";
2424
import "google/datastore/v1/entity.proto";
2525
import "google/datastore/v1/query.proto";
26+
import "google/datastore/v1/query_profile.proto";
2627
import "google/protobuf/timestamp.proto";
2728

2829
option csharp_namespace = "Google.Cloud.Datastore.V1";
@@ -232,6 +233,11 @@ message RunQueryRequest {
232233
// The GQL query to run. This query must be a non-aggregation query.
233234
GqlQuery gql_query = 7;
234235
}
236+
237+
// Optional. The mode in which the query request is processed. This field is
238+
// optional, and when not provided, it defaults to `NORMAL` mode where no
239+
// additional statistics will be returned with the query results.
240+
QueryMode mode = 11 [(google.api.field_behavior) = OPTIONAL];
235241
}
236242

237243
// The response for
@@ -251,6 +257,12 @@ message RunQueryResponse {
251257
// was set in
252258
// [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
253259
bytes transaction = 5;
260+
261+
// Query plan and execution statistics. Note that the returned stats are
262+
// subject to change as Firestore evolves.
263+
//
264+
// This is only present when the request specifies a mode other than `NORMAL`.
265+
ResultSetStats stats = 6;
254266
}
255267

256268
// The request for
@@ -282,6 +294,11 @@ message RunAggregationQueryRequest {
282294
// The GQL query to run. This query must be an aggregation query.
283295
GqlQuery gql_query = 7;
284296
}
297+
298+
// Optional. The mode in which the query request is processed. This field is
299+
// optional, and when not provided, it defaults to `NORMAL` mode where no
300+
// additional statistics will be returned with the query results.
301+
QueryMode mode = 10 [(google.api.field_behavior) = OPTIONAL];
285302
}
286303

287304
// The response for
@@ -301,6 +318,12 @@ message RunAggregationQueryResponse {
301318
// was set in
302319
// [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
303320
bytes transaction = 5;
321+
322+
// Query plan and execution statistics. Note that the returned stats are
323+
// subject to change as Firestore evolves.
324+
//
325+
// This is only present when the request specifies a mode other than `NORMAL`.
326+
ResultSetStats stats = 6;
304327
}
305328

306329
// The request for
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.datastore.v1;
18+
19+
import "google/protobuf/struct.proto";
20+
21+
option csharp_namespace = "Google.Cloud.Datastore.V1";
22+
option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore";
23+
option java_multiple_files = true;
24+
option java_outer_classname = "QueryProfileProto";
25+
option java_package = "com.google.datastore.v1";
26+
option php_namespace = "Google\\Cloud\\Datastore\\V1";
27+
option ruby_package = "Google::Cloud::Datastore::V1";
28+
29+
// Specification of the Datastore Query Profile fields.
30+
31+
// The mode in which the query request must be processed.
32+
enum QueryMode {
33+
// The default mode. Only the query results are returned.
34+
NORMAL = 0;
35+
36+
// This mode returns only the query plan, without any results or execution
37+
// statistics information.
38+
PLAN = 1;
39+
40+
// This mode returns both the query plan and the execution statistics along
41+
// with the results.
42+
PROFILE = 2;
43+
}
44+
45+
// Plan for the query.
46+
message QueryPlan {
47+
// Planning phase information for the query. It will include:
48+
//
49+
// {
50+
// "indexes_used": [
51+
// {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
52+
// {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
53+
// ]
54+
// }
55+
google.protobuf.Struct plan_info = 1;
56+
}
57+
58+
// Planning and execution statistics for the query.
59+
message ResultSetStats {
60+
// Plan for the query.
61+
QueryPlan query_plan = 1;
62+
63+
// Aggregated statistics from the execution of the query.
64+
//
65+
// This will only be present when the request specifies `PROFILE` mode.
66+
// For example, a query will return the statistics including:
67+
//
68+
// {
69+
// "results_returned": "20",
70+
// "documents_scanned": "20",
71+
// "indexes_entries_scanned": "10050",
72+
// "total_execution_time": "100.7 msecs"
73+
// }
74+
google.protobuf.Struct query_stats = 2;
75+
}

0 commit comments

Comments
 (0)