# Database Center API . projects

## Instance Methods

AggregateQueryStats provides database resource query execution statistics.

Retrieves the next page of results.

Close httplib2 connections.

### Method Details

`aggregateQueryStats(parent, body=None, x__xgafv=None)`

    AggregateQueryStats provides database resource query execution statistics.

    Args:
      parent: string, Required. Parent can be a project, a folder, or an organization. The search is limited to the resources within the `parent`. The allowed values are: * projects/{PROJECT_ID} (e.g., "projects/foo-bar") * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") * folders/{FOLDER_NUMBER} (e.g., "folders/1234567") * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456") (required)
      body: object, The request body.
        The object takes the form of:

    { # AggregateQueryStatsRequest represents the input to the AggregateQueryStats method.
      "filter": "A String", # Optional. The expression to filter resources. Supported fields are: `full_resource_name`, `resource_type`, `container`, `product.type`, `product.engine`, `product.version`, `location`, `labels`, `issues`, fields of availability_info, data_protection_info,'resource_name', etc. The expression is a list of zero or more restrictions combined via logical operators `AND` and `OR`. When `AND` and `OR` are both used in the expression, parentheses must be appropriately used to group the combinations. Example: `location="us-east1"` Example: `container="projects/123" OR container="projects/456"` Example: `(container="projects/123" OR container="projects/456") AND location="us-east1"` Additional specific fields for query stats are: `metric_window`, `query_hash`, `normalized_query`. Example: `metric_window="LAST_ONE_DAY"` (Possible values for `metric_window` are: `LAST_ONE_DAY`, `LAST_ONE_WEEK`, `LAST_TWO_WEEKS`) Example: `query_hash="12345678"` Example: `normalized_query="SELECT * FROM table"`
      "orderBy": "A String", # Optional. The expression to order the results by. Example: `order_by="execution_count"` Example: `order_by="execution_count desc"` Supported order by fields are `execution_count`, `rows_processed`, `total_cpu_time`, `avg_cpu_time`.
      "pageSize": 42, # Optional. If unspecified, at most 100 query stats will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
      "pageToken": "A String", # Optional. A page token, received from a previous `AggregateQueryStatsRequest` call. Provide this to retrieve the subsequent page. All parameters except page_token should match the parameters in the call that provided the page token.
    }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # The response message containing relevant query stats for database resources.
      "nextPageToken": "A String", # A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
      "queryStats": [ # List of query stats where each group contains stats for resources having a particular combination of relevant query stats.
        { # QueryStatsInfo contains the aggregated and detailed query stats for a particular combination of relevant query stats for queries having same normalized query.
          "aggregatedQueryStats": { # QueryStats contains the stats for a particular combination of query_hash, query_string and resource_type. # Aggregated query stats for the resources for same normalized query.
            "inefficientQueryInfo": { # Metadata about inefficient query signal info for a database resource. # Information about inefficient query.
              "database": "A String", # Name of the database where index is required. For example, "db1", which is the name of the database present in the instance.
              "impactedQueriesCount": "A String", # Count of queries to be impacted if index is applied
              "sqlIndexStatement": "A String", # SQL statement of the index. Based on the ddl type, this will be either CREATE INDEX or DROP INDEX.
              "storageCostBytes": "A String", # Cost of additional disk usage in bytes
              "table": "A String", # Name of the table where index is required
            },
            "normalizedQuery": "A String", # The query string is normalized query without any PII data.
            "queryHash": "A String", # The query hash of the query.
            "queryMetrics": { # QueryMetrics contains the metrics related to the query execution. # Metrics related to the query performance.
              "avgCpuTime": "A String", # The average execution period of the query across all runs.
              "executionCount": "A String", # The number of times the query was executed.
              "metricsWindow": "A String", # The window over which the metrics are aggregated.
              "rowsProcessed": "A String", # The average number of rows processed by the query across all runs.
              "totalCpuTime": "A String", # The total CPU time consumed by the query across all runs.
            },
            "resourceIds": [ # The resource ids for which the query stats are collected.
              { # ResourceId contains the identifier for a database resource, including the full resource name, resource type, and product.
                "fullResourceName": "A String", # The full resource name of the resource.
                "product": { # Product specification for databasecenter resources. # The product of the resource, including the type, engine, and version.
                  "engine": "A String", # Optional. The specific engine that the underlying database is running.
                  "minorVersion": "A String", # Optional. Minor version of the underlying database engine. Example values: For MySQL, it could be "8.0.35", "5.7.25" etc. For PostgreSQL, it could be "14.4", "15.5" etc.
                  "type": "A String", # Optional. Type of specific database product. It could be CloudSQL, AlloyDB etc..
                  "version": "A String", # Optional. Version of the underlying database engine. Example values: For MySQL, it could be "8.0", "5.7" etc. For Postgres, it could be "14", "15" etc.
                },
                "resourceType": "A String", # The type of the resource. sqladmin.googleapis.com/Instance alloydb.googleapis.com/Cluster alloydb.googleapis.com/Instance
              },
            ],
            "resourceType": "A String", # The type of the resource. sqladmin.googleapis.com/Instance alloydb.googleapis.com/Cluster alloydb.googleapis.com/Instance
          },
          "queryStats": [ # List of query stats for the resources in the group. This stats is stats at resource level for the resources having same normalized query.
            { # QueryStats contains the stats for a particular combination of query_hash, query_string and resource_type.
              "inefficientQueryInfo": { # Metadata about inefficient query signal info for a database resource. # Information about inefficient query.
                "database": "A String", # Name of the database where index is required. For example, "db1", which is the name of the database present in the instance.
                "impactedQueriesCount": "A String", # Count of queries to be impacted if index is applied
                "sqlIndexStatement": "A String", # SQL statement of the index. Based on the ddl type, this will be either CREATE INDEX or DROP INDEX.
                "storageCostBytes": "A String", # Cost of additional disk usage in bytes
                "table": "A String", # Name of the table where index is required
              },
              "normalizedQuery": "A String", # The query string is normalized query without any PII data.
              "queryHash": "A String", # The query hash of the query.
              "queryMetrics": { # QueryMetrics contains the metrics related to the query execution. # Metrics related to the query performance.
                "avgCpuTime": "A String", # The average execution period of the query across all runs.
                "executionCount": "A String", # The number of times the query was executed.
                "metricsWindow": "A String", # The window over which the metrics are aggregated.
                "rowsProcessed": "A String", # The average number of rows processed by the query across all runs.
                "totalCpuTime": "A String", # The total CPU time consumed by the query across all runs.
              },
              "resourceIds": [ # The resource ids for which the query stats are collected.
                { # ResourceId contains the identifier for a database resource, including the full resource name, resource type, and product.
                  "fullResourceName": "A String", # The full resource name of the resource.
                  "product": { # Product specification for databasecenter resources. # The product of the resource, including the type, engine, and version.
                    "engine": "A String", # Optional. The specific engine that the underlying database is running.
                    "minorVersion": "A String", # Optional. Minor version of the underlying database engine. Example values: For MySQL, it could be "8.0.35", "5.7.25" etc. For PostgreSQL, it could be "14.4", "15.5" etc.
                    "type": "A String", # Optional. Type of specific database product. It could be CloudSQL, AlloyDB etc..
                    "version": "A String", # Optional. Version of the underlying database engine. Example values: For MySQL, it could be "8.0", "5.7" etc. For Postgres, it could be "14", "15" etc.
                  },
                  "resourceType": "A String", # The type of the resource. sqladmin.googleapis.com/Instance alloydb.googleapis.com/Cluster alloydb.googleapis.com/Instance
                },
              ],
              "resourceType": "A String", # The type of the resource. sqladmin.googleapis.com/Instance alloydb.googleapis.com/Cluster alloydb.googleapis.com/Instance
            },
          ],
        },
      ],
      "unreachable": [ # Unordered list. List of unreachable regions from where data could not be retrieved.
        "A String",
      ],
    }

`aggregateQueryStats_next()`

    Retrieves the next page of results.

            Args:
              previous_request: The request for the previous page. (required)
              previous_response: The response from the request for the previous page. (required)

            Returns:
              A request object that you can call 'execute()' on to request the next
              page. Returns None if there are no more items in the collection.

`close()`

    Close httplib2 connections.