Skip to content

Commit 2027807

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: 595771083
1 parent 4512234 commit 2027807

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

google/firestore/v1/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ proto_library(
2727
"document.proto",
2828
"firestore.proto",
2929
"query.proto",
30+
"query_profile.proto",
3031
"write.proto",
3132
],
3233
deps = [

google/firestore/v1/firestore.proto

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import "google/firestore/v1/aggregation_result.proto";
2323
import "google/firestore/v1/common.proto";
2424
import "google/firestore/v1/document.proto";
2525
import "google/firestore/v1/query.proto";
26+
import "google/firestore/v1/query_profile.proto";
2627
import "google/firestore/v1/write.proto";
2728
import "google/protobuf/empty.proto";
2829
import "google/protobuf/timestamp.proto";
@@ -576,6 +577,11 @@ message RunQueryRequest {
576577
// minute timestamp within the past 7 days.
577578
google.protobuf.Timestamp read_time = 7;
578579
}
580+
581+
// Optional. The mode in which the query request is processed. This field is
582+
// optional, and when not provided, it defaults to `NORMAL` mode where no
583+
// additional statistics will be returned with the query results.
584+
QueryMode mode = 9 [(google.api.field_behavior) = OPTIONAL];
579585
}
580586

581587
// The response for
@@ -612,6 +618,13 @@ message RunQueryResponse {
612618
// documents will be returned.
613619
bool done = 6;
614620
}
621+
622+
// Query plan and execution statistics. Note that the returned stats are
623+
// subject to change as Firestore evolves.
624+
//
625+
// This is only present when the request specifies a mode other than `NORMAL`
626+
// and is sent only once with the last response in the stream.
627+
ResultSetStats stats = 7;
615628
}
616629

617630
// The request for
@@ -651,6 +664,11 @@ message RunAggregationQueryRequest {
651664
// minute timestamp within the past 7 days.
652665
google.protobuf.Timestamp read_time = 6;
653666
}
667+
668+
// Optional. The mode in which the query request is processed. This field is
669+
// optional, and when not provided, it defaults to `NORMAL` mode where no
670+
// additional statistics will be returned with the query results.
671+
QueryMode mode = 7 [(google.api.field_behavior) = OPTIONAL];
654672
}
655673

656674
// The response for
@@ -676,6 +694,13 @@ message RunAggregationQueryResponse {
676694
// `result` will be sent, and this represents the time at which the query
677695
// was run.
678696
google.protobuf.Timestamp read_time = 3;
697+
698+
// Query plan and execution statistics. Note that the returned stats are
699+
// subject to change as Firestore evolves.
700+
//
701+
// This is only present when the request specifies a mode other than `NORMAL`
702+
// and is sent only once with the last response in the stream.
703+
ResultSetStats stats = 6;
679704
}
680705

681706
// The request for
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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.firestore.v1;
18+
19+
import "google/protobuf/struct.proto";
20+
21+
option csharp_namespace = "Google.Cloud.Firestore.V1";
22+
option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb";
23+
option java_multiple_files = true;
24+
option java_outer_classname = "QueryProfileProto";
25+
option java_package = "com.google.firestore.v1";
26+
option objc_class_prefix = "GCFS";
27+
option php_namespace = "Google\\Cloud\\Firestore\\V1";
28+
option ruby_package = "Google::Cloud::Firestore::V1";
29+
30+
// Specification of the Firestore Query Profile fields.
31+
32+
// The mode in which the query request must be processed.
33+
enum QueryMode {
34+
// The default mode. Only the query results are returned.
35+
NORMAL = 0;
36+
37+
// This mode returns only the query plan, without any results or execution
38+
// statistics information.
39+
PLAN = 1;
40+
41+
// This mode returns both the query plan and the execution statistics along
42+
// with the results.
43+
PROFILE = 2;
44+
}
45+
46+
// Plan for the query.
47+
message QueryPlan {
48+
// Planning phase information for the query. It will include:
49+
//
50+
// {
51+
// "indexes_used": [
52+
// {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
53+
// {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
54+
// ]
55+
// }
56+
google.protobuf.Struct plan_info = 1;
57+
}
58+
59+
// Planning and execution statistics for the query.
60+
message ResultSetStats {
61+
// Plan for the query.
62+
QueryPlan query_plan = 1;
63+
64+
// Aggregated statistics from the execution of the query.
65+
//
66+
// This will only be present when the request specifies `PROFILE` mode.
67+
// For example, a query will return the statistics including:
68+
//
69+
// {
70+
// "results_returned": "20",
71+
// "documents_scanned": "20",
72+
// "indexes_entries_scanned": "10050",
73+
// "total_execution_time": "100.7 msecs"
74+
// }
75+
google.protobuf.Struct query_stats = 2;
76+
}

0 commit comments

Comments
 (0)