Skip to content

Commit 5bfc6f4

Browse files
committed
Removing the extensions doc
1 parent c1e1955 commit 5bfc6f4

File tree

1 file changed

+1
-202
lines changed

1 file changed

+1
-202
lines changed

articles/azure-arc/data/using-extensions-in-postgresql-server.md

Lines changed: 1 addition & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -14,208 +14,7 @@ ms.topic: how-to
1414

1515
# Use PostgreSQL extensions in your Azure Arc-enabled PostgreSQL server
1616

17-
PostgreSQL is at its best when you use it with extensions. In fact, a key element of our own Hyperscale functionality is the Microsoft-provided `citus` extension that is installed by default, which allows Postgres to transparently shard data across multiple nodes.
18-
19-
[!INCLUDE [azure-arc-data-preview](../../../includes/azure-arc-data-preview.md)]
20-
21-
## Supported extensions
22-
The standard [`contrib`](https://www.postgresql.org/docs/12/contrib.html) extensions and the following extensions are already deployed in the containers of your Azure Arc-enabled PostgreSQL server:
23-
- [`citus`](https://github.com/citusdata/citus), v: 10.2. The Citus extension by [Citus Data](https://www.citusdata.com/) is loaded by default as it brings the Hyperscale capability to the PostgreSQL engine. Dropping the Citus extension from your Azure Arc PostgreSQL server is not supported.
24-
- [`pg_cron`](https://github.com/citusdata/pg_cron), v: 1.3
25-
- [`pgaudit`](https://www.pgaudit.org/), v: 1.4
26-
- plpgsql, v: 1.0
27-
- [`postgis`](https://postgis.net), v: 3.0.2
28-
- [`plv8`](https://plv8.github.io/), v: 2.3.14
29-
- [`pg_partman`](https://github.com/pgpartman/pg_partman), v: 4.4.1/
30-
- [`tdigest`](https://github.com/tvondra/tdigest), v: 1.0.1
31-
32-
Updates to this list will be posted as it evolves over time.
33-
34-
> [!IMPORTANT]
35-
> While you may bring to your server group an extension other than those listed above, in this Preview, it will not be persisted to your system. It means that it will not be available after a restart of the system and you would need to bring it again.
36-
37-
This guide will take in a scenario to use two of these extensions:
38-
- [`PostGIS`](https://postgis.net/)
39-
- [`pg_cron`](https://github.com/citusdata/pg_cron)
40-
41-
## Which extensions need to be added to the shared_preload_libraries and created?
42-
43-
|Extensions |Requires to be added to shared_preload_libraries |Requires to be created |
44-
|-------------|--------------------------------------------------|---------------------- |
45-
|`pg_cron` |No |Yes |
46-
|`pg_audit` |Yes |Yes |
47-
|`plpgsql` |Yes |Yes |
48-
|`postgis` |No |Yes |
49-
|`plv8` |No |Yes |
50-
51-
## Add extensions to the `shared_preload_libraries`
52-
For details about that are `shared_preload_libraries`, read the PostgreSQL documentation [here](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES):
53-
- This step isn't needed for the extensions that are part of `contrib`
54-
- this step isn't required for extensions that are not required to pre-load by shared_preload_libraries. For these extensions you may jump the next paragraph [Create extensions](#create-extensions).
55-
56-
### Add an extension to an instance that already exists
57-
```azurecli
58-
az postgres server-arc server edit -n <postgresql server> --extensions <extension names> --k8s-namespace <namespace> --use-k8s
59-
```
60-
61-
## Show the list of extensions added to shared_preload_libraries
62-
Run either of the following command.
63-
64-
### With CLI command
65-
```azurecli
66-
az postgres server-arc show -n <server name> --k8s-namespace <namespace> --use-k8s
67-
```
68-
Scroll in the output and notice the engine\extensions sections in the specifications of your server group. For example:
69-
```console
70-
"spec": {
71-
"dev": false,
72-
"engine": {
73-
"extensions": [
74-
{
75-
"name": "citus"
76-
}
77-
],
78-
```
79-
### With kubectl
80-
```console
81-
kubectl describe postgresqls/<server name> -n <namespace>
82-
```
83-
Scroll in the output and notice the engine\extensions sections in the specifications of your server group. For example:
84-
```console
85-
Spec:
86-
Dev: false
87-
Engine:
88-
Extensions:
89-
Name: citus
90-
```
91-
92-
93-
## Create extensions
94-
Connect to your server group with the client tool of your choice and run the standard PostgreSQL query:
95-
```console
96-
CREATE EXTENSION <extension name>;
97-
```
98-
99-
## Show the list of extensions created
100-
Connect to your server group with the client tool of your choice and run the standard PostgreSQL query:
101-
```console
102-
select * from pg_extension;
103-
```
104-
105-
## Drop an extension
106-
Connect to your server group with the client tool of your choice and run the standard PostgreSQL query:
107-
```console
108-
drop extension <extension name>;
109-
```
110-
111-
## The `PostGIS` extension
112-
You do not need to add the `PostGIS` extension to the `shared_preload_libraries`.
113-
Get [sample data](http://duspviz.mit.edu/tutorials/intro-postgis/) from the MIT’s Department of Urban Studies & Planning. Run `apt-get install unzip` to install unzip as needed.
114-
115-
```console
116-
wget http://duspviz.mit.edu/_assets/data/intro-postgis-datasets.zip
117-
unzip intro-postgis-datasets.zip
118-
```
119-
120-
Let's connect to our database, and create the `PostGIS` extension:
121-
122-
```console
123-
CREATE EXTENSION postgis;
124-
```
125-
126-
> [!NOTE]
127-
> If you would like to use one of the extensions in the `postgis` package (for example `postgis_raster`, `postgis_topology`, `postgis_sfcgal`, `fuzzystrmatch`...) you need to first create the postgis extension and then create the other extension. For instance: `CREATE EXTENSION postgis`; `CREATE EXTENSION postgis_raster`;
128-
129-
And create the schema:
130-
131-
```sql
132-
CREATE TABLE coffee_shops (
133-
id serial NOT NULL,
134-
name character varying(50),
135-
address character varying(50),
136-
city character varying(50),
137-
state character varying(50),
138-
zip character varying(10),
139-
lat numeric,
140-
lon numeric,
141-
geom geometry(POINT,4326)
142-
);
143-
CREATE INDEX coffee_shops_gist ON coffee_shops USING gist (geom);
144-
```
145-
146-
Now, we can combine `PostGIS` with the scale-out functionality, by making the coffee_shops table distributed:
147-
148-
```sql
149-
SELECT create_distributed_table('coffee_shops', 'id');
150-
```
151-
152-
Let's load some data:
153-
154-
```console
155-
\copy coffee_shops(id,name,address,city,state,zip,lat,lon) from cambridge_coffee_shops.csv CSV HEADER;
156-
```
157-
158-
And fill the `geom` field with the correctly encoded latitude and longitude in the `PostGIS` `geometry` data type:
159-
160-
```sql
161-
UPDATE coffee_shops SET geom = ST_SetSRID(ST_MakePoint(lon,lat),4326);
162-
```
163-
164-
Now we can list the coffee shops closest to MIT (77 Massachusetts Ave at 42.359055, -71.093500):
165-
166-
```sql
167-
SELECT name, address FROM coffee_shops ORDER BY geom <-> ST_SetSRID(ST_MakePoint(-71.093500,42.359055),4326);
168-
```
169-
170-
171-
## The `pg_cron` extension
172-
173-
Now, let's enable `pg_cron` on our PostgreSQL server group by adding it to the shared_preload_libraries:
174-
175-
```azurecli
176-
az postgres server-arc update -n pg2 -ns arc --extensions pg_cron
177-
```
178-
179-
Your server group will restart complete the installation of the extensions. It may take 2 to 3 minutes.
180-
181-
We can now connect again, and create the `pg_cron` extension:
182-
183-
```sql
184-
CREATE EXTENSION pg_cron;
185-
```
186-
187-
For test purposes, lets make a table `the_best_coffee_shop` that takes a random name from our earlier `coffee_shops` table, and inserts the table contents:
188-
189-
```sql
190-
CREATE TABLE the_best_coffee_shop(name text);
191-
```
192-
193-
We can use `cron.schedule` plus a few SQL statements, to get a random table name (notice the use of a temporary table to store a distributed query result), and store it in `the_best_coffee_shop`:
194-
195-
```sql
196-
SELECT cron.schedule('* * * * *', $$
197-
TRUNCATE the_best_coffee_shop;
198-
CREATE TEMPORARY TABLE tmp AS SELECT name FROM coffee_shops ORDER BY random() LIMIT 1;
199-
INSERT INTO the_best_coffee_shop SELECT * FROM tmp;
200-
DROP TABLE tmp;
201-
$$);
202-
```
203-
204-
And now, once a minute, we'll get a different name:
205-
206-
```sql
207-
SELECT * FROM the_best_coffee_shop;
208-
```
209-
210-
```console
211-
name
212-
-----------------
213-
B & B Snack Bar
214-
(1 row)
215-
```
216-
217-
See the [pg_cron README](https://github.com/citusdata/pg_cron) for full details on the syntax.
218-
17+
Extensions are not currently supported in this preview.
21918

22019
## Next steps
22120
- Read documentation on [`plv8`](https://plv8.github.io/)

0 commit comments

Comments
 (0)