Skip to content

Commit 6c409d5

Browse files
feat: add new types ExplainOptions, ExplainMetrics, PlanSummary, ExecutionStats (#1241)
* feat: add new types ExplainOptions, ExplainMetrics, PlanSummary, ExecutionStats feat: add ExplainOptions field to RunQueryRequest feat: add ExplainMetrics field to RunQueryResponse feat: add ExplainOptions field to RunAggregationQueryRequest feat: add ExplainMetrics field to RunAggregationQueryResponse PiperOrigin-RevId: 615158168 Source-Link: googleapis/googleapis@4d535ac Source-Link: googleapis/googleapis-gen@02e272d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDJlMjcyZGVkNTM4YjBmOTc4MzJiZmFkNDdkZWNiYzNkYzY1YTg5YSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8da7c39 commit 6c409d5

File tree

10 files changed

+1698
-41
lines changed

10 files changed

+1698
-41
lines changed

protos/google/datastore/v1/datastore.proto

Lines changed: 19 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,10 @@ 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. Explain options for the query. If set, additional query
238+
// statistics will be returned. If not, only query results will be returned.
239+
ExplainOptions explain_options = 12 [(google.api.field_behavior) = OPTIONAL];
235240
}
236241

237242
// The response for
@@ -251,6 +256,11 @@ message RunQueryResponse {
251256
// was set in
252257
// [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
253258
bytes transaction = 5;
259+
260+
// Query explain metrics. This is only present when the
261+
// [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
262+
// is provided, and it is sent only once with the last response in the stream.
263+
ExplainMetrics explain_metrics = 9;
254264
}
255265

256266
// The request for
@@ -282,6 +292,10 @@ message RunAggregationQueryRequest {
282292
// The GQL query to run. This query must be an aggregation query.
283293
GqlQuery gql_query = 7;
284294
}
295+
296+
// Optional. Explain options for the query. If set, additional query
297+
// statistics will be returned. If not, only query results will be returned.
298+
ExplainOptions explain_options = 11 [(google.api.field_behavior) = OPTIONAL];
285299
}
286300

287301
// The response for
@@ -301,6 +315,11 @@ message RunAggregationQueryResponse {
301315
// was set in
302316
// [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
303317
bytes transaction = 5;
318+
319+
// Query explain metrics. This is only present when the
320+
// [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
321+
// is provided, and it is sent only once with the last response in the stream.
322+
ExplainMetrics explain_metrics = 9;
304323
}
305324

306325
// The request for

protos/google/datastore/v1/query_profile.proto

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ syntax = "proto3";
1616

1717
package google.datastore.v1;
1818

19+
import "google/api/field_behavior.proto";
20+
import "google/protobuf/duration.proto";
1921
import "google/protobuf/struct.proto";
2022

2123
option csharp_namespace = "Google.Cloud.Datastore.V1";
@@ -28,48 +30,62 @@ option ruby_package = "Google::Cloud::Datastore::V1";
2830

2931
// Specification of the Datastore Query Profile fields.
3032

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;
33+
// Explain options for the query.
34+
message ExplainOptions {
35+
// Optional. Whether to execute this query.
36+
//
37+
// When false (the default), the query will be planned, returning only
38+
// metrics from the planning stages.
39+
//
40+
// When true, the query will be planned and executed, returning the full
41+
// query results along with both planning and execution stage metrics.
42+
bool analyze = 1 [(google.api.field_behavior) = OPTIONAL];
43+
}
3544

36-
// This mode returns only the query plan, without any results or execution
37-
// statistics information.
38-
PLAN = 1;
45+
// Explain metrics for the query.
46+
message ExplainMetrics {
47+
// Planning phase information for the query.
48+
PlanSummary plan_summary = 1;
3949

40-
// This mode returns both the query plan and the execution statistics along
41-
// with the results.
42-
PROFILE = 2;
50+
// Aggregated stats from the execution of the query. Only present when
51+
// [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
52+
// to true.
53+
ExecutionStats execution_stats = 2;
4354
}
4455

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+
// Planning phase information for the query.
57+
message PlanSummary {
58+
// The indexes selected for the query. For example:
59+
// [
60+
// {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
61+
// {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
62+
// ]
63+
repeated google.protobuf.Struct indexes_used = 1;
5664
}
5765

58-
// Planning and execution statistics for the query.
59-
message ResultSetStats {
60-
// Plan for the query.
61-
QueryPlan query_plan = 1;
66+
// Execution statistics for the query.
67+
message ExecutionStats {
68+
// Total number of results returned, including documents, projections,
69+
// aggregation results, keys.
70+
int64 results_returned = 1;
6271

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;
72+
// Total time to execute the query in the backend.
73+
google.protobuf.Duration execution_duration = 3;
74+
75+
// Total billable read operations.
76+
int64 read_operations = 4;
77+
78+
// Debugging statistics from the execution of the query. Note that the
79+
// debugging stats are subject to change as Firestore evolves. It could
80+
// include:
81+
// {
82+
// "indexes_entries_scanned": "1000",
83+
// "documents_scanned": "20",
84+
// "billing_details" : {
85+
// "documents_billable": "20",
86+
// "index_entries_billable": "1000",
87+
// "min_query_cost": "0"
88+
// }
89+
// }
90+
google.protobuf.Struct debug_stats = 5;
7591
}

0 commit comments

Comments
 (0)