SHOW POSTGRES INSTANCES¶
Lists the Snowflake Postgres instances for which you have access privileges.
- See also:
CREATE POSTGRES INSTANCE , ALTER POSTGRES INSTANCE, DESCRIBE POSTGRES INSTANCE , DROP POSTGRES INSTANCE
Syntax¶
SHOW POSTGRES INSTANCES [ LIKE '<pattern>' ]
[ STARTS WITH '<name_string>' ]
[ LIMIT <rows> [ FROM '<name_string>' ] ]
Parameters¶
LIKE 'pattern'Optionally filters the command output by object name. The filter uses case-insensitive pattern matching, with support for SQL wildcard characters (
%and_).For example, the following patterns return the same results:
... LIKE '%testing%' ...... LIKE '%TESTING%' .... Default: No value (no filtering is applied to the output).
STARTS WITH 'name_string'Optionally filters the command output based on the characters that appear at the beginning of the object name. The string must be enclosed in single quotes and is case sensitive.
For example, the following strings return different results:
... STARTS WITH 'B' ...... STARTS WITH 'b' .... Default: No value (no filtering is applied to the output)
LIMIT rows [ FROM 'name_string' ]Optionally limits the maximum number of rows returned, while also enabling “pagination” of the results. The actual number of rows returned might be less than the specified limit. For example, the number of existing objects is less than the specified limit.
The optional
FROM 'name_string'subclause effectively serves as a “cursor” for the results. This enables fetching the specified number of rows following the first row whose object name matches the specified string:The string must be enclosed in single quotes and is case sensitive.
The string does not have to include the full object name; partial names are supported.
Default: No value (no limit is applied to the output)
Note
For SHOW commands that support both the
FROM 'name_string'andSTARTS WITH 'name_string'clauses, you can combine both of these clauses in the same statement. However, both conditions must be met or they cancel out each other and no results are returned.In addition, objects are returned in lexicographic order by name, so
FROM 'name_string'only returns rows with a higher lexicographic value than the rows returned bySTARTS WITH 'name_string'.For example:
... STARTS WITH 'A' LIMIT ... FROM 'B'would return no results.... STARTS WITH 'B' LIMIT ... FROM 'A'would return no results.... STARTS WITH 'A' LIMIT ... FROM 'AB'would return results (if any rows match the input strings).
Output¶
The output of the command includes the following columns, which describe the properties and metadata of the object:
Column |
Description |
|---|---|
|
Name of the Postgres instance. |
|
Role that owns the Postgres instance. |
|
Type of the owner role (for example, ROLE or DATABASE_ROLE). |
|
Date and time when the Postgres instance was created. |
|
Date and time when the Postgres instance was last updated. |
|
Type of the Postgres instance. |
|
Origin of the Postgres instance (for example, if forked from another instance). |
|
Hostname used to connect to the Postgres instance. |
|
Identifier for the Private Link service, if Private Link is configured for the instance. |
|
Compute family (instance size) of the Postgres instance. |
|
Authentication method used for the instance (currently |
|
Storage size allocated to the Postgres instance, in GB. |
|
Major version of Postgres running on the instance. |
|
Custom Postgres server settings configured for the instance. |
|
Whether high availability is enabled for the instance. |
|
Data retention time for the instance. |
|
Current state of the instance. Possible values: |
|
Comment for the Postgres instance. |
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
Privilege |
Object |
Notes |
|---|---|---|
OPERATE or OWNERSHIP |
Postgres instance |
Only instances for which you have one of these privileges appear in the output. |
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Usage notes¶
The command doesn’t require a running warehouse to execute.
The command only returns objects for which the current user’s current role has been granted at least one access privilege.
The MANAGE GRANTS access privilege implicitly allows its holder to see every object in the account. By default, only the account administrator (users with the ACCOUNTADMIN role) and security administrator (users with the SECURITYADMIN role) have the MANAGE GRANTS privilege.
To post-process the output of this command, you can use the pipe operator (
->>) or the RESULT_SCAN function. Both constructs treat the output as a result set that you can query.For example, you can use the pipe operator or RESULT_SCAN function to select specific columns from the SHOW command output or filter the rows.
When you refer to the output columns, use double-quoted identifiers for the column names. For example, to select the output column
type, specifySELECT "type".You must use double-quoted identifiers because the output column names for SHOW commands are in lowercase. The double quotes ensure that the column names in the SELECT list or WHERE clause match the column names in the SHOW command output that was scanned.
The command returns a maximum of ten thousand records for the specified object type, as dictated by the access privileges for the role used to execute the command. Any records above the ten thousand records limit aren’t returned, even with a filter applied.
To view results for which more than ten thousand records exist, query the corresponding view (if one exists) in the Snowflake Information Schema.
Use this command to monitor the state and configuration of your Postgres instances for capacity planning, troubleshooting, and auditing purposes.
Common use cases include checking instance states during operations, identifying instances that need upgrades, and reviewing storage usage across your account.
Examples¶
List all Postgres instances in the account:
SHOW POSTGRES INSTANCES;
List Postgres instances with names starting with prod:
SHOW POSTGRES INSTANCES STARTS WITH 'PROD';
List Postgres instances matching a pattern:
SHOW POSTGRES INSTANCES LIKE 'DEV_%';
Use the flow operator to filter and select specific columns:
SHOW POSTGRES INSTANCES
->> SELECT "name", "state", "compute_family", "storage_size"
FROM $1
WHERE "state" = 'READY'
ORDER BY "name";
Find all instances with high availability enabled:
SHOW POSTGRES INSTANCES
->> SELECT "name", "compute_family", "is_ha", "postgres_version"
FROM $1
WHERE "is_ha" = 'true';
Get a summary of storage usage across all instances:
SHOW POSTGRES INSTANCES
->> SELECT "name", "storage_size", "created_on"
FROM $1
WHERE "storage_size" > 100
ORDER BY "storage_size" DESC;