Skip to content

Commit e9cf5af

Browse files
authored
Merge pull request #185469 from jonels-msft/hsc-new-quickstart
Separate Hyperscale quickstart into more digestible pieces
2 parents 37680fe + 3ff80c0 commit e9cf5af

17 files changed

+334
-325
lines changed

articles/postgresql/.openpublishing.redirection.postgresql.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@
310310
"redirect_url": "/azure/postgresql/hyperscale/concepts-server-group",
311311
"redirect_document_id": false
312312
},
313+
{
314+
"source_path_from_root": "/articles/postgresql/hyperscale/quickstart-create-basic-tier.md",
315+
"redirect_url": "/azure/postgresql/hyperscale/quickstart-create-portal",
316+
"redirect_document_id": false
317+
},
318+
{
319+
"source_path_from_root": "/articles/postgresql/hyperscale/tutorial-server-group.md",
320+
"redirect_url": "/azure/postgresql/hyperscale/quickstart-create-portal",
321+
"redirect_document_id": false
322+
},
313323
{
314324
"source_path_from_root": "/articles/postgresql/policy-samples.md",
315325
"redirect_url": "/azure/postgresql/policy-reference",

articles/postgresql/TOC.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,21 @@
619619
items:
620620
- name: Create server group
621621
items:
622-
- name: Basic tier
623-
href: hyperscale/quickstart-create-basic-tier.md
624-
- name: Standard tier
622+
- name: Azure portal
625623
href: hyperscale/quickstart-create-portal.md
626624
displayName: portal, create hyperscale
625+
- name: Connect
626+
items:
627+
- name: psql
628+
href: hyperscale/quickstart-connect-psql.md
629+
- name: Model and load data
630+
items:
631+
- name: Create and distribute tables
632+
href: hyperscale/quickstart-distribute-tables.md
633+
- name: Run queries
634+
href: hyperscale/quickstart-run-queries.md
627635
- name: Tutorials
628636
items:
629-
- name: Create a server group
630-
href: hyperscale/tutorial-server-group.md
631637
- name: Model and load data
632638
items:
633639
- name: Shard data on worker nodes

articles/postgresql/hyperscale/concepts-server-group.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,34 @@ applications with the basic tier and later [graduate to the standard
5959
tier](howto-scale-grow.md#add-worker-nodes) with confidence that the
6060
interface remains the same.
6161

62-
The basic tier is also appropriate for smaller workloads in production. There
63-
is room to scale vertically *within* the basic tier by increasing the number of
62+
The basic tier is also appropriate for smaller workloads in production. There’s
63+
room to scale vertically *within* the basic tier by increasing the number of
6464
server vCores.
6565

6666
When greater scale is required right away, use the standard tier. Its smallest
6767
allowed server group has one coordinator node and two workers. You can choose
6868
to use more nodes based on your use-case, as described in our [initial
6969
sizing](howto-scale-initial.md) how-to.
7070

71+
#### Tier summary
72+
73+
**Basic tier**
74+
75+
* 2 to 8 vCores, 8 to 32 gigabytes of memory.
76+
* Consists of a single database node, which can be scaled vertically.
77+
* Supports sharding on a single node and can be easily upgraded to a standard tier.
78+
* Economical deployment option for initial development, testing.
79+
80+
**Standard tier**
81+
82+
* 8 to 1000+ vCores, up to 8+ TiB memory
83+
* Distributed Postgres cluster, which consists of a dedicated coordinator
84+
node and at least two worker nodes.
85+
* Supports Sharding on multiple worker nodes. The cluster can be scaled
86+
horizontally by adding new worker nodes, and scaled vertically by
87+
increasing the node vCores.
88+
* Best for performance and scale.
89+
7190
## Next steps
7291

7392
* Learn to [provision the basic tier](quickstart-create-basic-tier.md)

articles/postgresql/hyperscale/howto-create-users.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ comes with several roles pre-defined:
2424
* `citus`
2525

2626
Since Hyperscale (Citus) is a managed PaaS service, only Microsoft can sign in with the
27-
`postgres` super user role. For limited administrative access, Hyperscale (Citus)
27+
`postgres` superuser role. For limited administrative access, Hyperscale (Citus)
2828
provides the `citus` role.
2929

3030
Permissions for the `citus` role:
3131

3232
* Read all configuration variables, even variables normally visible only to
3333
superusers.
34-
* Read all pg\_stat\_\* views and use various statistics-related extensions --
35-
even views or extensions normally visible only to superusers.
34+
* Read all pg\_stat\_\* views and use various statistics-related
35+
extensions--even views or extensions normally visible only to superusers.
3636
* Execute monitoring functions that may take ACCESS SHARE locks on tables,
3737
potentially for a long time.
3838
* [Create PostgreSQL extensions](concepts-extensions.md) (because
@@ -48,26 +48,26 @@ Notably, the `citus` role has some restrictions:
4848
As mentioned, the `citus` admin account lacks permission to create additional
4949
users. To add a user, use the Azure portal interface.
5050

51-
1. Go to the **Roles** page for your Hyperscale (Citus) server group, and click **+ Add**:
51+
1. Go to the **Roles** page for your Hyperscale (Citus) server group, and
52+
select **+ Add**:
5253

5354
:::image type="content" source="../media/howto-hyperscale-create-users/1-role-page.png" alt-text="The roles page":::
5455

55-
2. Enter the role name and password. Click **Save**.
56+
2. Enter the role name and password. Select **Save**.
5657

5758
:::image type="content" source="../media/howto-hyperscale-create-users/2-add-user-fields.png" alt-text="Add role":::
5859

5960
The user will be created on the coordinator node of the server group,
6061
and propagated to all the worker nodes. Roles created through the Azure
61-
portal have the `LOGIN` attribute, which means they are true users who
62+
portal have the `LOGIN` attribute, which means they’re true users who
6263
can sign in to the database.
6364

6465
## How to modify privileges for user role
6566

6667
New user roles are commonly used to provide database access with restricted
6768
privileges. To modify user privileges, use standard PostgreSQL commands, using
68-
a tool such as PgAdmin or psql. (See [connecting with
69-
psql](quickstart-create-portal.md#connect-to-the-database-using-psql)
70-
in the Hyperscale (Citus) quickstart.)
69+
a tool such as PgAdmin or psql. (See [Connect to a Hyperscale (Citus) server
70+
group](quickstart-connect-psql.md).)
7171

7272
For example, to allow `db_user` to read `mytable`, grant the permission:
7373

@@ -77,7 +77,7 @@ GRANT SELECT ON mytable TO db_user;
7777

7878
Hyperscale (Citus) propagates single-table GRANT statements through the entire
7979
cluster, applying them on all worker nodes. It also propagates GRANTs that are
80-
system-wide (e.g. for all tables in a schema):
80+
system-wide (for example, for all tables in a schema):
8181

8282
```sql
8383
-- applies to the coordinator node and propagates to workers
@@ -87,7 +87,7 @@ GRANT SELECT ON ALL TABLES IN SCHEMA public TO db_user;
8787
## How to delete a user role or change their password
8888

8989
To update a user, visit the **Roles** page for your Hyperscale (Citus) server group,
90-
and click the ellipses **...** next to the user. The ellipses will open a menu
90+
and select the ellipses **...** next to the user. The ellipses will open a menu
9191
to delete the user or reset their password.
9292

9393
:::image type="content" source="../media/howto-hyperscale-create-users/edit-role.png" alt-text="Edit a role":::
@@ -100,7 +100,7 @@ Open the firewall for the IP addresses of the new users' machines to enable
100100
them to connect: [Create and manage Hyperscale (Citus) firewall rules using
101101
the Azure portal](howto-manage-firewall-using-portal.md).
102102

103-
For more information about database user account management, see PostgreSQL
103+
For more information about database user management, see PostgreSQL
104104
product documentation:
105105

106106
* [Database Roles and Privileges](https://www.postgresql.org/docs/current/static/user-manag.html)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: 'Quickstart: connect to a server group with psql - Hyperscale (Citus) - Azure Database for PostgreSQL'
3+
description: Quickstart to connect psql to Azure Database for PostgreSQL - Hyperscale (Citus).
4+
author: jonels-msft
5+
ms.author: jonels
6+
ms.service: postgresql
7+
ms.subservice: hyperscale-citus
8+
ms.custom: mvc, mode-ui
9+
ms.topic: quickstart
10+
ms.date: 01/24/2022
11+
---
12+
13+
# Connect to a Hyperscale (Citus) server group with psql
14+
15+
## Prerequisites
16+
17+
To follow this quickstart, you'll first need to:
18+
19+
* [Create a server group](quickstart-create-portal.md) in the Azure portal.
20+
21+
## Connect
22+
23+
When you create your Azure Database for PostgreSQL server, a default database named **citus** is created. To connect to your database server, you need a connection string and the admin password.
24+
25+
1. Obtain the connection string. In the server group page, select the **Connection strings** menu item. (It's under **Settings**.) Find the string marked **psql**. It will be of the form, `psql "host=hostname.postgres.database.azure.com port=5432 dbname=citus user=citus password={your_password} sslmode=require"`
26+
27+
Copy the string. You’ll need to replace "{your\_password}" with the administrative password you chose earlier. The system doesn't store your plaintext password and so can't display it for you in the connection string.
28+
29+
2. Open a terminal window on your local computer.
30+
31+
3. At the prompt, connect to your Azure Database for PostgreSQL server with the [psql](https://www.postgresql.org/docs/current/app-psql.html) utility. Pass your connection string in quotes, being sure it contains your password:
32+
```bash
33+
psql "host=..."
34+
```
35+
36+
For example, the following command connects to the coordinator node of the server group **mydemoserver**:
37+
38+
```bash
39+
psql "host=mydemoserver-c.postgres.database.azure.com port=5432 dbname=citus user=citus password={your_password} sslmode=require"
40+
```
41+
42+
## Next steps
43+
44+
* [Troubleshoot connection problems](howto-troubleshoot-common-connection-issues.md).
45+
* Learn to [create and distribute tables](quickstart-distribute-tables.md).

articles/postgresql/hyperscale/quickstart-create-basic-tier.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

articles/postgresql/hyperscale/quickstart-create-portal.md

Lines changed: 12 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -7,134 +7,26 @@ ms.service: postgresql
77
ms.subservice: hyperscale-citus
88
ms.custom: mvc, mode-ui
99
ms.topic: quickstart
10-
ms.date: 11/16/2021
10+
ms.date: 01/24/2022
1111
#Customer intent: As a developer, I want to provision a hyperscale server group so that I can run queries quickly on large datasets.
1212
---
1313

14-
# Quickstart: create a Hyperscale (Citus) server group in the Azure portal
14+
# Create a Hyperscale (Citus) server group in the Azure portal
1515

1616
Azure Database for PostgreSQL is a managed service that you use to run, manage, and scale highly available PostgreSQL databases in the cloud. This Quickstart shows you how to create an Azure Database for PostgreSQL - Hyperscale (Citus) server group using the Azure portal. You'll explore distributed data: sharding tables across nodes, ingesting sample data, and running queries that execute on multiple nodes.
1717

18-
[!INCLUDE [azure-postgresql-hyperscale-create-db](../../../includes/azure-postgresql-hyperscale-create-db.md)]
19-
20-
## Create and distribute tables
21-
22-
Once connected to the hyperscale coordinator node using psql, you can complete some basic tasks.
23-
24-
Within Hyperscale (Citus) servers there are three types of tables:
25-
26-
- Distributed or sharded tables (spread out to help scaling for performance and parallelization)
27-
- Reference tables (multiple copies maintained)
28-
- Local tables (often used for internal admin tables)
29-
30-
In this quickstart, we'll primarily focus on distributed tables and getting familiar with them.
31-
32-
The data model we're going to work with is simple: user and event data from GitHub. Events include fork creation, git commits related to an organization, and more.
33-
34-
Once you've connected via psql, let's create our tables. In the psql console run:
35-
36-
```sql
37-
CREATE TABLE github_events
38-
(
39-
event_id bigint,
40-
event_type text,
41-
event_public boolean,
42-
repo_id bigint,
43-
payload jsonb,
44-
repo jsonb,
45-
user_id bigint,
46-
org jsonb,
47-
created_at timestamp
48-
);
49-
50-
CREATE TABLE github_users
51-
(
52-
user_id bigint,
53-
url text,
54-
login text,
55-
avatar_url text,
56-
gravatar_id text,
57-
display_login text
58-
);
59-
```
60-
61-
The `payload` field of `github_events` has a JSONB datatype. JSONB is the JSON datatype in binary form in Postgres. The datatype makes it easy to store a flexible schema in a single column.
62-
63-
Postgres can create a `GIN` index on this type, which will index every key and value within it. With an index, it becomes fast and easy to query the payload with various conditions. Let's go ahead and create a couple of indexes before we load our data. In psql:
64-
65-
```sql
66-
CREATE INDEX event_type_index ON github_events (event_type);
67-
CREATE INDEX payload_index ON github_events USING GIN (payload jsonb_path_ops);
68-
```
69-
70-
Next we’ll take those Postgres tables on the coordinator node and tell Hyperscale (Citus) to shard them across the workers. To do so, we’ll run a query for each table specifying the key to shard it on. In the current example we’ll shard both the events and users table on `user_id`:
71-
72-
```sql
73-
SELECT create_distributed_table('github_events', 'user_id');
74-
SELECT create_distributed_table('github_users', 'user_id');
75-
```
7618

77-
[!INCLUDE [azure-postgresql-hyperscale-dist-alert](../../../includes/azure-postgresql-hyperscale-dist-alert.md)]
19+
Azure Database for PostgreSQL - Hyperscale (Citus) is a managed service that
20+
you use to run, manage, and scale highly available PostgreSQL databases in the
21+
cloud. Its [basic tier](concepts-server-group.md#tiers) is a convenient
22+
deployment option for initial development and testing.
7823

79-
We're ready to load data. In psql still, shell out to download the files:
24+
This quickstart shows you how to create a Hyperscale (Citus) basic tier server
25+
group using the Azure portal. You'll create the server group and verify that
26+
you can connect to it to run queries.
8027

81-
```sql
82-
\! curl -O https://examples.citusdata.com/users.csv
83-
\! curl -O https://examples.citusdata.com/events.csv
84-
```
85-
86-
Next, load the data from the files into the distributed tables:
87-
88-
```sql
89-
SET CLIENT_ENCODING TO 'utf8';
90-
91-
\copy github_events from 'events.csv' WITH CSV
92-
\copy github_users from 'users.csv' WITH CSV
93-
```
94-
95-
## Run queries
96-
97-
Now it's time for the fun part, actually running some queries. Let's start with a simple `count (*)` to see how much data we loaded:
98-
99-
```sql
100-
SELECT count(*) from github_events;
101-
```
102-
103-
That worked nicely. We'll come back to that sort of aggregation in a bit, but for now let’s look at a few other queries. Within the JSONB `payload` column there's a good bit of data, but it varies based on event type. `PushEvent` events contain a size that includes the number of distinct commits for the push. We can use it to find the total number of commits per hour:
104-
105-
```sql
106-
SELECT date_trunc('hour', created_at) AS hour,
107-
sum((payload->>'distinct_size')::int) AS num_commits
108-
FROM github_events
109-
WHERE event_type = 'PushEvent'
110-
GROUP BY hour
111-
ORDER BY hour;
112-
```
113-
114-
So far the queries have involved the github\_events exclusively, but we can combine this information with github\_users. Since we sharded both users and events on the same identifier (`user_id`), the rows of both tables with matching user IDs will be [colocated](concepts-colocation.md) on the same database nodes and can easily be joined.
115-
116-
If we join on `user_id`, Hyperscale (Citus) can push the join execution down into shards for execution in parallel on worker nodes. For example, let's find the users who created the greatest number of repositories:
117-
118-
```sql
119-
SELECT gu.login, count(*)
120-
FROM github_events ge
121-
JOIN github_users gu
122-
ON ge.user_id = gu.user_id
123-
WHERE ge.event_type = 'CreateEvent'
124-
AND ge.payload @> '{"ref_type": "repository"}'
125-
GROUP BY gu.login
126-
ORDER BY count(*) DESC;
127-
```
128-
129-
## Clean up resources
130-
131-
In the preceding steps, you created Azure resources in a server group. If you don't expect to need these resources in the future, delete the server group. Press the **Delete** button in the **Overview** page for your server group. When prompted on a pop-up page, confirm the name of the server group and click the final **Delete** button.
132-
133-
## Next steps
28+
[!INCLUDE [azure-postgresql-hyperscale-create-db](../../../includes/azure-postgresql-hyperscale-create-db.md)]
13429

135-
In this quickstart, you learned how to provision a Hyperscale (Citus) server group. You connected to it with psql, created a schema, and distributed data.
30+
**Next steps**
13631

137-
- Follow a tutorial to [build scalable multi-tenant
138-
applications](./tutorial-design-database-multi-tenant.md)
139-
- Determine the best [initial
140-
size](howto-scale-initial.md) for your server group
32+
* [Connect to your server group](quickstart-connect-psql.md) with psql.

0 commit comments

Comments
 (0)