You can extend PostgreSQL by bundling SQL objects into a package and using them as a unit. This page contains information about configuring the PostgreSQL extensions that Cloud SQL supports.
Use PostgreSQL extensionsYou can install only the extensions that Cloud SQL supports. For more information, see PostgreSQL extensions supported by Cloud SQL.
Note: You can only install extensions on the primary instance, not the read replica. Once installed, the extension replicates to the read replica. Install an extensionBefore using an extension, install it:
pglogical
. For more information, see Configure external replicas. Requirement for superuser privileges
In Cloud SQL, extensions can only be created by users that are part of the cloudsqlsuperuser
role. When you create a new PostgreSQL instance, the default postgres
user is created for you (although you must set the user's password). The default postgres
user is part of the cloudsqlsuperuser
role. For more information, see About PostgreSQL users.
The target instances for connections must be in the same VPC network as the connecting instance.
For cluster instances, you can't choose the Require trusted client certificates option in the Google Cloud console. Additionally, to connect to databases within the same instance, you cannot set host to localhost or to 127.0.0.1
. Instead, you must use the IP address shown for your instance in the Google Cloud console.
You cannot create your own extensions in Cloud SQL.
To request support for an extension, click +1 on the open issue or create a new issue. For a list of open Cloud SQL issues and information about creating new issues, see Search for or create issues and feature requests, by product.
PostgreSQL extensions supported by Cloud SQLFor information about using a specific extension, see the documentation link in one of the tables below.
Cloud SQL support for PostgreSQL extensions can be divided into these categories:
PostGISThe PostGIS extension is supported for Cloud SQL for PostgreSQL for all major versions.
The following table contains the PostGIS extension versions for each Cloud SQL for PostgreSQL version:
Cloud SQL for PostgreSQL version PostGIS extension PostgreSQL 9.6 3.2.5 PostgreSQL 10 3.2.5 PostgreSQL 11 3.2.5 PostgreSQL 12 3.4.4 PostgreSQL 13 3.5.2 PostgreSQL 14 3.5.2 PostgreSQL 15 3.5.2 PostgreSQL 16 3.5.2 PostgreSQL 17 3.5.2For a specific PostgreSQL major version, in the CREATE EXTENSION command, you can specify a PostGIS extension version by using the VERSION
clause.
The PostGIS extension includes the following:
postgis
postgis_raster
postgis_sfcgal
postgis_tiger_geocoder
postgis_topology
address_standardizer
address_standardizer_data_us
For more information, see PostGIS Installation.
Additionally, Cloud SQL for PostgreSQL includes version 3.6.2 of the pgRouting
extension, which extends PostGIS. The pgRouting
extension enhances geospatial processing through network routing and analysis.
You can upgrade PostGIS and its related extensions to their latest version manually. To learn more about upgrading your PostGIS extensions, see Upgrading PostGIS.
Data type extensions Extension Description btree_gin Provides sample GIN operator classes that implement B-tree equivalent behavior.chkpass
that is designed for storing encrypted passwords.
citext
.
cube
for representing multidimensional cubes.
hstore
data type for storing sets of key/value pairs within a single PostgreSQL value.
ltree
for representing labels of data stored in a hierarchical tree-like structure.
hll
, which is a HyperLogLog data structure. Also see postgresql-hll in this document.
timestamp
field. You can use this to track the last time that a row in a database table is modified.
Possible values to set for the audit log files for all versions of pgAudit are READ
, WRITE
, FUNCTION
, ROLE
, DDL
, MISC
, and ALL
. For versions 1.4.2 and above, you can also set the value of MISC_SET
.
For more information about using this extension with Cloud SQL, see Audit for PostgreSQL using pgAudit.
pg_background Lets you run arbitrary commands in a background worker.pgoutput
is a default plugin and is therefore supported on all versions of Cloud SQL for PostgreSQL. pg_ivm Enables you to make materialized views up-to-date in which only incremental changes are computed and applied on views rather than recomputing the contents from scratch.
Creates and manages DB2 or Oracle-style global temporary tables in a PostgreSQL database.
PostgreSQL 9.6, 10 and 11 use version 3.0. PostgreSQL 12 and later use version 4.0.
An open-source extension for storing and searching vector embeddings in PostgreSQL databases.
PostgreSQL versions 13 and later support version 0.8.0, PostgreSQL version 12 supports up to version 0.7.4, and PostgreSQL version 11 supports up to version 0.5.1.
extended
. For versions 13 and later, the storage mode is external
for optimal performance. If you're using pgvector 0.6.0 with version 12, and then upgrade to a major version, we recommend that you modify the storage mode to external
as follows:
ALTER TYPE vector SET (STORAGE = external);
. pg_visibility Provides a way to examine the visibility map (VM) and the page-level visibility information of a table. Also see pg_visibility in this document.
Masks or replaces personally identifiable information (PII) or sensitive data from a PostgreSQL database. For more information, see the postgresql_anonymizer section.
Cloud SQL for PostgreSQL uses version 1.0.0.
postgresql_hllProvides a HyperLogLog (hll
) data structure that estimates the cardinality of a set.
Cloud SQL for PostgreSQL uses version 2.18.
rdkit A collection of cheminformatics and machine-learning software. You can use this extension for comparing, manipulating, and identifying molecular structures.This section describes more information about some of the supported PostgreSQL extensions in the tables above.
auto_explainTo begin using this extension on an instance, set the cloudsql.enable_auto_explain
flag to on
. For information about setting flags, and to review the flags supported for this extension, see Configure database flags.
To view logging data and events that are associated with the logs of the execution plans that this extension enables, see the Cloud Logging documentation.
Alternatively, for a user that has the cloudsqlsuperuser
role (only), you can use the load
command to load this extension for one session.
From within a database session, you can use this extension to connect to PostgreSQL databases and execute queries.
Currently, this extension works for two Cloud SQL private IP instances within the same VPC network, or for cross databases within the same instance.
Note: In Cloud SQL, the use of client certificates with dblink isn't supported.For additional information, see dblink in the PostgreSQL documentation.
Use dblink to connect with a passwordTo connect to databases, or to connect to the same instance as another user, you must specify a password. For example purposes (but not for production purposes), here is a code snippet:
SELECT * FROM dblink (
'dbname=name port=1234 host=host user=user password=password',
'select id, name from table' \
) AS t(id int, name text);
Alternatively, to only set up a connection, here is a code snippet for example purposes (not for production purposes):
SELECT dblink_connect('dbname=dblinktest user=postgres host=name_or_ip password=xxx');
Use dblink to connect without a password
To connect to the same instance as the same user, you can connect without a password. For example:
Set the following database flag to enable local connections without a passwordcloudsql.allow_passwordless_local_connections
Connect without specifying a host, which implies connecting to the same instance. Here is an example:
SELECT *
FROM dblink('dbname=finance user=alice',
'select income from revenue')
AS revenue(income integer);
The result could be similar to the following:
income
--------
1000
(1 row)
To connect to databases within the same instance, you cannot set host to localhost or to 127.0.0.1
. Instead, you must use the IP address shown for your instance in the Google Cloud console.
Also see postgres_fdw and PL/Proxy in this document.
pageinspectThis extension inspects the contents of database pages at a low level. For more information, see pageinspect in the PostgreSQL documentation.
pg_bigmThis extension enables full-text search, and allows a two-gram (bigram) index for faster full-text search.
To begin using this extension on an instance, set the cloudsql.enable_pg_bigm
flag to on
. The following flags also are supported:
pg_bigm.enable_recheck
pg_bigm.gin_key_limit
pg_bigm.similarity_limit
For information about setting flags, and to review the flags supported for this extension, see Configure database flags.
pg_cronTo begin using pg_cron on an instance, set the cloudsql.enable_pg_cron
flag to on
. For information about setting flags, and to review the flags supported for this extension, see Configure database flags.
The jobs are configured as background workers, so you might need to use standard PostgreSQL techniques (such as the max_worker_processes
flag) to adjust the number of those background workers.
For this extension, Cloud SQL supports the background worker mode, but not the libpq interface. Therefore, trust authentication directly involving this extension is not required.
pgfincoreThis extension contains functions for managing pages in operating system disk cache memory from PostgreSQL. For more information, see the pgfincore documentation.
pg_freespacemapThis extension examines the free space map (FSM). For more information, see pg_freespacemap in the PostgreSQL documentation.
pg_hint_planTo begin using this extension on an instance, set the cloudsql.enable_pg_hint_plan
flag to on
. For information about setting flags, and to review the flags supported for this extension, see Configure database flags.
Alternatively, for only a user with the cloudsqlsuperuser
role, you can use the load
command to load this extension for one session.
This extension enables you to create and manage time-based and serial-based table partition sets.
In Cloud SQL, this extension doesn't include the background worker for automatic partition maintenance. Instead, you can use, for example, Cloud Scheduler to drive maintenance by calling maintenance functions at a regular interval.
pg_proctabHere are the steps to use the pg_proctab extension to enable the pg_top utility:
-r
option for connecting to a remote database, for getting metrics.The following instance-wide metrics, which are included in the output, include usage by other supporting agents and services in the instance:
This extension enables you to remove bloat from tables and indexes. Optionally, you can use this extension to perform an online CLUSTER (order tables by cluster index). For more information, see the pg_repack documentation. Additionally, for use of this extension in Cloud SQL, a special procedure is needed for adding privileges to a user.
If a user outside of the cloudsqlsuperuser
role wants to use an extension, you must grant the user cloudsqlsuperuser
privileges. For more information, in this document, see Requirement for superuser privileges. The following example uses the GRANT
command to add the necessary privileges.
For example purposes below, csuper1
is a cloudsqlsuperuser
and testdb
is a database owned by testuser
. To create the pg_repack extension in testdb
, initially run the following commands:
Connect to testdb
as the cloudsqlsuperuser
:
psql -U csuper1 -d testdb;
Grant the database owner, which is testuser,
to csuper1
:
GRANT testuser TO csuper1;
Create the extension:
CREATE EXTENSION pg_repack;
Run the pg_repack
command on a table, such as t1
in testdb
, as csuper1
:
pg_repack -h <hostname> -d testdb -U csuper1 -k -t t1
After the pg_repack job is completed, revoke the grant that you performed in step 2:
REVOKE testuser FROM csuper1;
The pg_repack
command might fail with the following error:"ERROR: query failed: SSL SYSCALL error: EOF detected"
If that error occurs, try setting TCP keepalives to a smaller value and then run the pg_repack
command. For more information, see Connections timeout (from Compute Engine).
This extension removes unused space from a table and optionally uses an index to sort tuples of the table. To begin using the extension on an instance, set the cloudsql.enable_pg_squeeze
flag to on
.
This extension also supports logical decoding by writing additional information to the write-ahead log (WAL). To enable this functionality for the extension, set the wal_level
configuration parameter to logical
or higher by setting the cloudsql.logical_decoding
flag to on
.
The extension requires a value to be set for the max_replication_slots
flag. If you haven't specified a value for this flag, then set the value to 1
. Otherwise, add 1 to the value that's set for the flag.
For information about setting flags, and to review the flags supported for this extension, see Configure database flags.
pgttTo begin using this extension on an instance, set the pgtt.enabled
flag to on
. For information about setting flags, and to review the flags supported for this extension, see Configuring database flags.
This extension provides a way to examine the visibility map (VM) and the page-level visibility information of a table. For more information, see pg_visibility in the PostgreSQL documentation.
PL/ProxyThis extension is a procedural language handler that allows remote procedure calls among PostgreSQL databases, with optional sharding.
For more information, see the PL/Proxy documentation.
The target instances for connections must be in the same VPC network as the connecting instance. Additionally, you cannot choose, in the Google Cloud console, the Allow only SSL connections button for cluster instances.
To connect to databases within the same instance, you cannot set host to localhost or to 127.0.0.1
. Instead, you must use the IP address shown for your instance in the Google Cloud console.
Also see postgres_fdw and dblink in this document.
postgresql_anonymizerTo begin using this extension on an instance, set the cloudsql.enable_anon
flag to on
. For information about setting flags, and to review the flags supported for this extension, see Configuring database flags.
This extension allows tables from other ("foreign") PostgreSQL databases to be exposed as "foreign" tables in the current database. Those tables then are available for use, almost as if they were local tables. For more information, see postgres_fdw in the PostgreSQL documentation.
This extension works for two Cloud SQL private IP instances within the same VPC network, or for cross databases within the same instance.
To connect to databases within the same instance, you cannot set host to localhost or to 127.0.0.1
. Instead, you must use the IP address shown for your instance in the Google Cloud console.
Additionally, for an instance where foreign data is stored, you can choose the Allow only SSL connections option in the Google Cloud console. You can't choose the Require trusted client certificates option. Only the cloudsqlsuperuser
can be the owner of a postgres_fdw
foreign data wrapper.
Also see PL/Proxy and dblink in this document.
postgresql-hllThis extension introduces a new data type, hll
, which is a HyperLogLog data structure. For more information, see the postgresql-hll documentation.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4