query_plan.proto 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Copyright 2022 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. syntax = "proto3";
  15. package google.spanner.v1;
  16. import "google/protobuf/struct.proto";
  17. option csharp_namespace = "Google.Cloud.Spanner.V1";
  18. option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
  19. option java_multiple_files = true;
  20. option java_outer_classname = "QueryPlanProto";
  21. option java_package = "com.google.spanner.v1";
  22. option php_namespace = "Google\\Cloud\\Spanner\\V1";
  23. option ruby_package = "Google::Cloud::Spanner::V1";
  24. // Node information for nodes appearing in a [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].
  25. message PlanNode {
  26. // The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of
  27. // nodes that can appear in a query plan.
  28. enum Kind {
  29. // Not specified.
  30. KIND_UNSPECIFIED = 0;
  31. // Denotes a Relational operator node in the expression tree. Relational
  32. // operators represent iterative processing of rows during query execution.
  33. // For example, a `TableScan` operation that reads rows from a table.
  34. RELATIONAL = 1;
  35. // Denotes a Scalar node in the expression tree. Scalar nodes represent
  36. // non-iterable entities in the query plan. For example, constants or
  37. // arithmetic operators appearing inside predicate expressions or references
  38. // to column names.
  39. SCALAR = 2;
  40. }
  41. // Metadata associated with a parent-child relationship appearing in a
  42. // [PlanNode][google.spanner.v1.PlanNode].
  43. message ChildLink {
  44. // The node to which the link points.
  45. int32 child_index = 1;
  46. // The type of the link. For example, in Hash Joins this could be used to
  47. // distinguish between the build child and the probe child, or in the case
  48. // of the child being an output variable, to represent the tag associated
  49. // with the output variable.
  50. string type = 2;
  51. // Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds
  52. // to an output variable of the parent node. The field carries the name of
  53. // the output variable.
  54. // For example, a `TableScan` operator that reads rows from a table will
  55. // have child links to the `SCALAR` nodes representing the output variables
  56. // created for each column that is read by the operator. The corresponding
  57. // `variable` fields will be set to the variable names assigned to the
  58. // columns.
  59. string variable = 3;
  60. }
  61. // Condensed representation of a node and its subtree. Only present for
  62. // `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode].
  63. message ShortRepresentation {
  64. // A string representation of the expression subtree rooted at this node.
  65. string description = 1;
  66. // A mapping of (subquery variable name) -> (subquery node id) for cases
  67. // where the `description` string of this node references a `SCALAR`
  68. // subquery contained in the expression subtree rooted at this node. The
  69. // referenced `SCALAR` subquery may not necessarily be a direct child of
  70. // this node.
  71. map<string, int32> subqueries = 2;
  72. }
  73. // The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes].
  74. int32 index = 1;
  75. // Used to determine the type of node. May be needed for visualizing
  76. // different kinds of nodes differently. For example, If the node is a
  77. // [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation
  78. // which can be used to directly embed a description of the node in its
  79. // parent.
  80. Kind kind = 2;
  81. // The display name for the node.
  82. string display_name = 3;
  83. // List of child node `index`es and their relationship to this parent.
  84. repeated ChildLink child_links = 4;
  85. // Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes.
  86. ShortRepresentation short_representation = 5;
  87. // Attributes relevant to the node contained in a group of key-value pairs.
  88. // For example, a Parameter Reference node could have the following
  89. // information in its metadata:
  90. //
  91. // {
  92. // "parameter_reference": "param1",
  93. // "parameter_type": "array"
  94. // }
  95. google.protobuf.Struct metadata = 6;
  96. // The execution statistics associated with the node, contained in a group of
  97. // key-value pairs. Only present if the plan was returned as a result of a
  98. // profile query. For example, number of executions, number of rows/time per
  99. // execution etc.
  100. google.protobuf.Struct execution_stats = 7;
  101. }
  102. // Contains an ordered list of nodes appearing in the query plan.
  103. message QueryPlan {
  104. // The nodes in the query plan. Plan nodes are returned in pre-order starting
  105. // with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in
  106. // `plan_nodes`.
  107. repeated PlanNode plan_nodes = 1;
  108. }