Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/firestore_v1/types/query_profile.py: 95%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

20 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2025 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16from __future__ import annotations 

17 

18from typing import MutableMapping, MutableSequence 

19 

20import proto # type: ignore 

21 

22from google.protobuf import duration_pb2 # type: ignore 

23from google.protobuf import struct_pb2 # type: ignore 

24 

25 

26__protobuf__ = proto.module( 

27 package="google.firestore.v1", 

28 manifest={ 

29 "ExplainOptions", 

30 "ExplainMetrics", 

31 "PlanSummary", 

32 "ExecutionStats", 

33 }, 

34) 

35 

36 

37class ExplainOptions(proto.Message): 

38 r"""Explain options for the query. 

39 

40 Attributes: 

41 analyze (bool): 

42 Optional. Whether to execute this query. 

43 

44 When false (the default), the query will be 

45 planned, returning only metrics from the 

46 planning stages. 

47 

48 When true, the query will be planned and 

49 executed, returning the full query results along 

50 with both planning and execution stage metrics. 

51 """ 

52 

53 analyze: bool = proto.Field( 

54 proto.BOOL, 

55 number=1, 

56 ) 

57 

58 

59class ExplainMetrics(proto.Message): 

60 r"""Explain metrics for the query. 

61 

62 Attributes: 

63 plan_summary (google.cloud.firestore_v1.types.PlanSummary): 

64 Planning phase information for the query. 

65 execution_stats (google.cloud.firestore_v1.types.ExecutionStats): 

66 Aggregated stats from the execution of the query. Only 

67 present when 

68 [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] 

69 is set to true. 

70 """ 

71 

72 plan_summary: "PlanSummary" = proto.Field( 

73 proto.MESSAGE, 

74 number=1, 

75 message="PlanSummary", 

76 ) 

77 execution_stats: "ExecutionStats" = proto.Field( 

78 proto.MESSAGE, 

79 number=2, 

80 message="ExecutionStats", 

81 ) 

82 

83 

84class PlanSummary(proto.Message): 

85 r"""Planning phase information for the query. 

86 

87 Attributes: 

88 indexes_used (MutableSequence[google.protobuf.struct_pb2.Struct]): 

89 The indexes selected for the query. For example: [ 

90 {"query_scope": "Collection", "properties": "(foo ASC, 

91 **name** ASC)"}, {"query_scope": "Collection", "properties": 

92 "(bar ASC, **name** ASC)"} ] 

93 """ 

94 

95 indexes_used: MutableSequence[struct_pb2.Struct] = proto.RepeatedField( 

96 proto.MESSAGE, 

97 number=1, 

98 message=struct_pb2.Struct, 

99 ) 

100 

101 

102class ExecutionStats(proto.Message): 

103 r"""Execution statistics for the query. 

104 

105 Attributes: 

106 results_returned (int): 

107 Total number of results returned, including 

108 documents, projections, aggregation results, 

109 keys. 

110 execution_duration (google.protobuf.duration_pb2.Duration): 

111 Total time to execute the query in the 

112 backend. 

113 read_operations (int): 

114 Total billable read operations. 

115 debug_stats (google.protobuf.struct_pb2.Struct): 

116 Debugging statistics from the execution of the query. Note 

117 that the debugging stats are subject to change as Firestore 

118 evolves. It could include: { "indexes_entries_scanned": 

119 "1000", "documents_scanned": "20", "billing_details" : { 

120 "documents_billable": "20", "index_entries_billable": 

121 "1000", "min_query_cost": "0" } } 

122 """ 

123 

124 results_returned: int = proto.Field( 

125 proto.INT64, 

126 number=1, 

127 ) 

128 execution_duration: duration_pb2.Duration = proto.Field( 

129 proto.MESSAGE, 

130 number=3, 

131 message=duration_pb2.Duration, 

132 ) 

133 read_operations: int = proto.Field( 

134 proto.INT64, 

135 number=4, 

136 ) 

137 debug_stats: struct_pb2.Struct = proto.Field( 

138 proto.MESSAGE, 

139 number=5, 

140 message=struct_pb2.Struct, 

141 ) 

142 

143 

144__all__ = tuple(sorted(__protobuf__.manifest))