Files
genai-toolbox/docs/en/resources/tools/postgres/postgres-list-database-stats.md
Yuan Teoh 293c1d6889 feat!: update configuration file v2 (#2369)
This PR introduces a significant update to the Toolbox configuration
file format, which is one of the primary **breaking changes** required
for the implementation of the Advanced Control Plane.

# Summary of Changes
The configuration schema has been updated to enforce resource isolation
and facilitate atomic, incremental updates.
* Resource Isolation: Resource definitions are now separated into
individual blocks, using a distinct structure for each resource type
(Source, Tool, Toolset, etc.). This improves readability, management,
and auditing of configuration files.
* Field Name Modification: Internal field names have been modified to
align with declarative methodologies. Specifically, the configuration
now separates kind (general resource type, e.g., Source) from type
(specific implementation, e.g., Postgres).

# User Impact
Existing tools.yaml configuration files are now in an outdated format.
Users must eventually update their files to the new YAML format.

# Mitigation & Compatibility
Backward compatibility is maintained during this transition to ensure no
immediate user action is required for existing files.
* Immediate Backward Compatibility: The source code includes a
pre-processing layer that automatically detects outdated configuration
files (v1 format) and converts them to the new v2 format under the hood.
* [COMING SOON] Migration Support: The new toolbox migrate subcommand
will be introduced to allow users to automatically convert their old
configuration files to the latest format.

# Example
Example for config file v2:
```
kind: sources
name: my-pg-instance
type: cloud-sql-postgres
project: my-project
region: my-region
instance: my-instance
database: my_db
user: my_user
password: my_pass
---
kind: authServices
name: my-google-auth
type: google
clientId: testing-id
---
kind: tools
name: example_tool
type: postgres-sql
source: my-pg-instance
description: some description
statement: SELECT * FROM SQL_STATEMENT;
parameters:
- name: country
  type: string
  description: some description
---
kind: tools
name: example_tool_2
type: postgres-sql
source: my-pg-instance
description: returning the number one
statement: SELECT 1;
---
kind: toolsets
name: example_toolset
tools:
- example_tool
```

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com>
2026-01-27 16:58:43 -08:00

5.1 KiB

title, type, weight, description, aliases
title type weight description aliases
postgres-list-database-stats docs 1 The "postgres-list-database-stats" tool lists lists key performance and activity statistics of PostgreSQL databases.
/resources/tools/postgres-list-database-stats

About

The postgres-list-database-stats lists the key performance and activity statistics for each PostgreSQL database in the instance, offering insights into cache efficiency, transaction throughput, row-level activity, temporary file usage, and contention. It's compatible with any of the following sources:

postgres-list-database-stats lists detailed information as JSON for each database. The tool takes the following input parameters:

  • database_name (optional): A text to filter results by database name. Default: ""
  • include_templates (optional): Boolean, set to true to include template databases in the results. Default: false
  • database_owner (optional): A text to filter results by database owner. Default: ""
  • default_tablespace (optional): A text to filter results by the default tablespace name. Default: ""
  • order_by (optional): Specifies the sorting order. Valid values are 'size' (descending) or 'commit' (descending). Default: database_name ascending.
  • limit (optional): The maximum number of databases to return. Default: 10

Example

kind: tools
name: list_database_stats
type: postgres-list-database-stats
source: postgres-source
description: |
  Lists the key performance and activity statistics for each PostgreSQL
  database in the instance, offering insights into cache efficiency,
  transaction throughput row-level activity, temporary file usage, and
  contention. It returns: the database name, whether the database is
  connectable, database owner, default tablespace name, the percentage of
  data blocks found in the buffer cache rather than being read from disk
  (a higher value indicates better cache performance), the total number of
  disk blocks read from disk, the total number of times disk blocks were
  found already in the cache; the total number of committed transactions,
  the total number of rolled back transactions, the percentage of rolled
  back transactions compared to the total number of completed
  transactions, the total number of rows returned by queries, the total
  number of live rows fetched by scans, the total number of rows inserted,
  the total number of rows updated, the total number of rows deleted, the
  number of temporary files created by queries, the total size of
  temporary files used by queries in bytes, the number of query
  cancellations due to conflicts with recovery, the number of deadlocks
  detected, the current number of active backend connections, the
  timestamp when the database statistics were last reset, and the total
  database size in bytes.

The response is a json array with the following elements:

{
 "database_name": "Name of the database",
 "is_connectable": "Boolean indicating Whether the database allows connections",
 "database_owner": "Username of the database owner",
 "default_tablespace": "Name of the default tablespace for the database",
 "cache_hit_ratio_percent": "The percentage of data blocks found in the buffer cache rather than being read from disk",
 "blocks_read_from_disk": "The total number of disk blocks read for this database",
 "blocks_hit_in_cache": "The total number of times disk blocks were found already in the cache.",
 "xact_commit": "The total number of committed transactions",
 "xact_rollback": "The total number of rolled back transactions",
 "rollback_ratio_percent": "The percentage of rolled back transactions compared to the total number of completed transactions",
 "rows_returned_by_queries": "The total number of rows returned by queries",
 "rows_fetched_by_scans": "The total number of live rows fetched by scans",
 "tup_inserted": "The total number of rows inserted",
 "tup_updated": "The total number of rows updated",
 "tup_deleted": "The total number of rows deleted",
 "temp_files": "The number of temporary files created by queries",
 "temp_size_bytes": "The total size of temporary files used by queries in bytes",
 "conflicts": "Number of query cancellations due to conflicts",
 "deadlocks": "Number of deadlocks detected",
 "active_connections": "The current number of active backend connections",
 "statistics_last_reset": "The timestamp when the database statistics were last reset",
 "database_size_bytes": "The total disk size of the database in bytes"
}

Reference

field type required description
type string true Must be "postgres-list-database-stats".
source string true Name of the source the SQL should execute on.
description string false Description of the tool that is passed to the agent.