Skip to content

Commit 3f04f9a

Browse files
committed
Update concepts-extensions.md
1 parent 83c7239 commit 3f04f9a

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

articles/postgresql/flexible-server/concepts-extensions.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ The following extensions are available in Azure Database for PostgreSQL - Flexib
152152
> |[pg_freespacemap](https://www.postgresql.org/docs/13/pgfreespacemap.html) | 1.2 | examine the free space map (FSM)|
153153
> |[pg_partman](https://github.com/pgpartman/pg_partman) | 4.5.0 | Extension to manage partitioned tables by time or ID |
154154
> |[pg_prewarm](https://www.postgresql.org/docs/13/pgprewarm.html) | 1.2 | prewarm relation data|
155+
> |[pg_repack](https://github.com/reorg/pg_repack) | 1.4.7 | reorganize tables in PostgreSQL databases with minimal locks|
155156
> |[pg_stat_statements](https://www.postgresql.org/docs/13/pgstatstatements.html) | 1.8 | track execution statistics of all SQL statements executed|
156157
> |[pg_trgm](https://www.postgresql.org/docs/13/pgtrgm.html) | 1.5 | text similarity measurement and index searching based on trigrams|
157158
> |[pg_visibility](https://www.postgresql.org/docs/13/pgvisibility.html) | 1.2 | examine the visibility map (VM) and page-level visibility info|
@@ -208,6 +209,7 @@ The following extensions are available in Azure Database for PostgreSQL - Flexib
208209
> |[pg_freespacemap](https://www.postgresql.org/docs/12/pgfreespacemap.html) | 1.2 | examine the free space map (FSM)|
209210
> |[pg_partman](https://github.com/pgpartman/pg_partman) | 4.5.0 | Extension to manage partitioned tables by time or ID |
210211
> |[pg_prewarm](https://www.postgresql.org/docs/12/pgprewarm.html) | 1.2 | prewarm relation data|
212+
> |[pg_repack](https://github.com/reorg/pg_repack) | 1.4.7 | reorganize tables in PostgreSQL databases with minimal locks|
211213
> |[pg_stat_statements](https://www.postgresql.org/docs/12/pgstatstatements.html) | 1.7 | track execution statistics of all SQL statements executed|
212214
> |[pg_trgm](https://www.postgresql.org/docs/12/pgtrgm.html) | 1.4 | text similarity measurement and index searching based on trigrams|
213215
> |[pg_visibility](https://www.postgresql.org/docs/12/pgvisibility.html) | 1.2 | examine the visibility map (VM) and page-level visibility info|
@@ -264,6 +266,7 @@ The following extensions are available in Azure Database for PostgreSQL - Flexib
264266
> |[pg_freespacemap](https://www.postgresql.org/docs/11/pgfreespacemap.html) | 1.2 | examine the free space map (FSM)|
265267
> |[pg_partman](https://github.com/pgpartman/pg_partman) | 4.5.0 | Extension to manage partitioned tables by time or ID |
266268
> |[pg_prewarm](https://www.postgresql.org/docs/11/pgprewarm.html) | 1.2 | prewarm relation data|
269+
> |[pg_repack](https://github.com/reorg/pg_repack) | 1.4.7 | reorganize tables in PostgreSQL databases with minimal locks|
267270
> |[pg_stat_statements](https://www.postgresql.org/docs/11/pgstatstatements.html) | 1.6 | track execution statistics of all SQL statements executed|
268271
> |[pg_trgm](https://www.postgresql.org/docs/11/pgtrgm.html) | 1.4 | text similarity measurement and index searching based on trigrams|
269272
> |[pg_visibility](https://www.postgresql.org/docs/11/pgvisibility.html) | 1.2 | examine the visibility map (VM) and page-level visibility info|
@@ -328,6 +331,75 @@ The setting `pg_stat_statements.track`, which controls what statements are count
328331
There is a tradeoff between the query execution information pg_stat_statements provides and the impact on server performance as it logs each SQL statement. If you are not actively using the pg_stat_statements extension, we recommend that you set `pg_stat_statements.track` to `none`. Note that some third party monitoring services may rely on pg_stat_statements to deliver query performance insights, so confirm whether this is the case for you or not.
329332

330333

334+
## TimescaleDB
335+
336+
TimescaleDB is a time-series database that is packaged as an extension for PostgreSQL. TimescaleDB provides time-oriented analytical functions, optimizations, and scales Postgres for time-series workloads.
337+
[Learn more about TimescaleDB](https://docs.timescale.com/timescaledb/latest/), a registered trademark of Timescale, Inc.. Azure Database for PostgreSQL provides the TimescaleDB [Apache-2 edition](https://www.timescale.com/legal/licenses).
338+
## Installing TimescaleDB
339+
To install TimescaleDB, you need to include it in the server's shared preload libraries. A change to Postgres's `shared_preload_libraries` parameter requires a **server restart** to take effect. You can change parameters using the [Azure portal](howto-configure-server-parameters-using-portal.md) or the [Azure CLI](howto-configure-server-parameters-using-cli.md).
340+
341+
Using the [Azure portal](https://portal.azure.com/):
342+
343+
1. Select your Azure Database for PostgreSQL server.
344+
345+
2. On the sidebar, select **Server Parameters**.
346+
347+
3. Search for the `shared_preload_libraries` parameter.
348+
349+
4. Select **TimescaleDB**.
350+
351+
5. Select **Save** to preserve your changes. You get a notification once the change is saved.
352+
353+
6. After the notification, **restart** the server to apply these changes.
354+
355+
356+
You can now enable TimescaleDB in your Postgres database. Connect to the database and issue the following command:
357+
```sql
358+
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
359+
```
360+
> [!TIP]
361+
> If you see an error, confirm that you [restarted your server](how-to-restart-server-portal.md) after saving shared_preload_libraries.
362+
363+
You can now create a TimescaleDB hypertable [from scratch](https://docs.timescale.com/getting-started/creating-hypertables) or migrate [existing time-series data in PostgreSQL](https://docs.timescale.com/getting-started/migrating-data).
364+
365+
### Restoring a Timescale database using pg_dump and pg_restore
366+
To restore a Timescale database using pg_dump and pg_restore, you need to run two helper procedures in the destination database: `timescaledb_pre_restore()` and `timescaledb_post restore()`.
367+
368+
First prepare the destination database:
369+
370+
```SQL
371+
--create the new database where you'll perform the restore
372+
CREATE DATABASE tutorial;
373+
\c tutorial --connect to the database
374+
CREATE EXTENSION timescaledb;
375+
376+
SELECT timescaledb_pre_restore();
377+
```
378+
379+
Now you can run pg_dump on the original database and then do pg_restore. After the restore, be sure to run the following command in the restored database:
380+
381+
```SQL
382+
SELECT timescaledb_post_restore();
383+
```
384+
For more details on restore method wiith Timescale enabled database see [Timescale documentation](https://docs.timescale.com/timescaledb/latest/how-to-guides/backup-and-restore/pg-dump-and-restore/#restore-your-entire-database-from-backup)
385+
386+
387+
### Restoring a Timescale database using timescaledb-backup
388+
389+
While running `SELECT timescaledb_post_restore()` procedure listed above you may get permissions denied error updating timescaledb.restoring flag. This is due to limited ALTER DATABASE permission in Cloud PaaS database services. In this case you can perform alternative method using `timescaledb-backup` tool to backup and restore Timescale database. Timescaledb-backup is a program for making dumping and restoring a TimescaleDB database simpler, less error-prone, and more performant.
390+
To do so you should do following
391+
1. Install tools as detailed [here](https://github.com/timescale/timescaledb-backup#installing-timescaledb-backup)
392+
2. Create target Azure Database for PostgreSQL server and database
393+
3. Enable Timescale extension as shown above
394+
4. Grant azure_pg_admin [role](https://www.postgresql.org/docs/11/database-roles.html) to user that will be used by [ts-restore](https://github.com/timescale/timescaledb-backup#using-ts-restore)
395+
5. Run [ts-restore](https://github.com/timescale/timescaledb-backup#using-ts-restore) to restore database
396+
397+
More details on these utilities can be found [here](https://github.com/timescale/timescaledb-backup).
398+
> [!NOTE]
399+
> When using `timescale-backup` utilities to restore to Azure is that since database user names for non-flexible Azure Database for PostgresQL must use the `<user@db-name>` format, you need to replace `@` with `%40` character encoding.
400+
401+
402+
331403
## Next steps
332404

333405
If you don't see an extension that you'd like to use, let us know. Vote for existing requests or create new feedback requests in our [feedback forum](https://feedback.azure.com/d365community/forum/c5e32b97-ee24-ec11-b6e6-000d3a4f0da0).

0 commit comments

Comments
 (0)