Skip to content

Commit 5d8ff15

Browse files
authored
Merge pull request #190945 from GennadNY/gennadyk986
Update concepts-extensions.md
2 parents c030e4f + 3f04f9a commit 5d8ff15

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
@@ -153,6 +153,7 @@ The following extensions are available in Azure Database for PostgreSQL - Flexib
153153
> |[pg_freespacemap](https://www.postgresql.org/docs/13/pgfreespacemap.html) | 1.2 | examine the free space map (FSM)|
154154
> |[pg_partman](https://github.com/pgpartman/pg_partman) | 4.5.0 | Extension to manage partitioned tables by time or ID |
155155
> |[pg_prewarm](https://www.postgresql.org/docs/13/pgprewarm.html) | 1.2 | prewarm relation data|
156+
> |[pg_repack](https://github.com/reorg/pg_repack) | 1.4.7 | reorganize tables in PostgreSQL databases with minimal locks|
156157
> |[pg_stat_statements](https://www.postgresql.org/docs/13/pgstatstatements.html) | 1.8 | track execution statistics of all SQL statements executed|
157158
> |[pg_trgm](https://www.postgresql.org/docs/13/pgtrgm.html) | 1.5 | text similarity measurement and index searching based on trigrams|
158159
> |[pg_visibility](https://www.postgresql.org/docs/13/pgvisibility.html) | 1.2 | examine the visibility map (VM) and page-level visibility info|
@@ -209,6 +210,7 @@ The following extensions are available in Azure Database for PostgreSQL - Flexib
209210
> |[pg_freespacemap](https://www.postgresql.org/docs/12/pgfreespacemap.html) | 1.2 | examine the free space map (FSM)|
210211
> |[pg_partman](https://github.com/pgpartman/pg_partman) | 4.5.0 | Extension to manage partitioned tables by time or ID |
211212
> |[pg_prewarm](https://www.postgresql.org/docs/12/pgprewarm.html) | 1.2 | prewarm relation data|
213+
> |[pg_repack](https://github.com/reorg/pg_repack) | 1.4.7 | reorganize tables in PostgreSQL databases with minimal locks|
212214
> |[pg_stat_statements](https://www.postgresql.org/docs/12/pgstatstatements.html) | 1.7 | track execution statistics of all SQL statements executed|
213215
> |[pg_trgm](https://www.postgresql.org/docs/12/pgtrgm.html) | 1.4 | text similarity measurement and index searching based on trigrams|
214216
> |[pg_visibility](https://www.postgresql.org/docs/12/pgvisibility.html) | 1.2 | examine the visibility map (VM) and page-level visibility info|
@@ -265,6 +267,7 @@ The following extensions are available in Azure Database for PostgreSQL - Flexib
265267
> |[pg_freespacemap](https://www.postgresql.org/docs/11/pgfreespacemap.html) | 1.2 | examine the free space map (FSM)|
266268
> |[pg_partman](https://github.com/pgpartman/pg_partman) | 4.5.0 | Extension to manage partitioned tables by time or ID |
267269
> |[pg_prewarm](https://www.postgresql.org/docs/11/pgprewarm.html) | 1.2 | prewarm relation data|
270+
> |[pg_repack](https://github.com/reorg/pg_repack) | 1.4.7 | reorganize tables in PostgreSQL databases with minimal locks|
268271
> |[pg_stat_statements](https://www.postgresql.org/docs/11/pgstatstatements.html) | 1.6 | track execution statistics of all SQL statements executed|
269272
> |[pg_trgm](https://www.postgresql.org/docs/11/pgtrgm.html) | 1.4 | text similarity measurement and index searching based on trigrams|
270273
> |[pg_visibility](https://www.postgresql.org/docs/11/pgvisibility.html) | 1.2 | examine the visibility map (VM) and page-level visibility info|
@@ -329,6 +332,75 @@ The setting `pg_stat_statements.track`, which controls what statements are count
329332
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.
330333

331334

335+
## TimescaleDB
336+
337+
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.
338+
[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).
339+
## Installing TimescaleDB
340+
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).
341+
342+
Using the [Azure portal](https://portal.azure.com/):
343+
344+
1. Select your Azure Database for PostgreSQL server.
345+
346+
2. On the sidebar, select **Server Parameters**.
347+
348+
3. Search for the `shared_preload_libraries` parameter.
349+
350+
4. Select **TimescaleDB**.
351+
352+
5. Select **Save** to preserve your changes. You get a notification once the change is saved.
353+
354+
6. After the notification, **restart** the server to apply these changes.
355+
356+
357+
You can now enable TimescaleDB in your Postgres database. Connect to the database and issue the following command:
358+
```sql
359+
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
360+
```
361+
> [!TIP]
362+
> If you see an error, confirm that you [restarted your server](how-to-restart-server-portal.md) after saving shared_preload_libraries.
363+
364+
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).
365+
366+
### Restoring a Timescale database using pg_dump and pg_restore
367+
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()`.
368+
369+
First prepare the destination database:
370+
371+
```SQL
372+
--create the new database where you'll perform the restore
373+
CREATE DATABASE tutorial;
374+
\c tutorial --connect to the database
375+
CREATE EXTENSION timescaledb;
376+
377+
SELECT timescaledb_pre_restore();
378+
```
379+
380+
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:
381+
382+
```SQL
383+
SELECT timescaledb_post_restore();
384+
```
385+
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)
386+
387+
388+
### Restoring a Timescale database using timescaledb-backup
389+
390+
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.
391+
To do so you should do following
392+
1. Install tools as detailed [here](https://github.com/timescale/timescaledb-backup#installing-timescaledb-backup)
393+
2. Create target Azure Database for PostgreSQL server and database
394+
3. Enable Timescale extension as shown above
395+
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)
396+
5. Run [ts-restore](https://github.com/timescale/timescaledb-backup#using-ts-restore) to restore database
397+
398+
More details on these utilities can be found [here](https://github.com/timescale/timescaledb-backup).
399+
> [!NOTE]
400+
> 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.
401+
402+
403+
332404
## Next steps
333405

334406
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)