Skip to content

Commit

Permalink
[docs] Add how to display tablespaces (#19338)
Browse files Browse the repository at this point in the history
* Show tablespaces

* meta-command

* port to stable
  • Loading branch information
ddhodge authored Oct 2, 2023
1 parent 5a20b8d commit 30d74fb
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/vale-styles/Yugabyte/MeaningfulLinkWords.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
extends: existence
message: 'Improve SEO and accessibility by rewriting "%s" in the link text.'
level: warning
scope: link
scope: raw
ignorecase: true
#link: https://about.gitlab.com/handbook/communication/#writing-style-guidelines
tokens:
- here
- this page
- this page
8 changes: 6 additions & 2 deletions docs/content/preview/admin/ysqlsh-meta-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Performs a frontend (client) copy. This is an operation that runs an SQL `COPY`

When program is specified, *command* is executed by ysqlsh and the data passed from or to *command* is routed between the server and the client. Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required.

For `\copy ... from stdin`, data rows are read from the same source that issued the command, continuing until `\.` is read or the stream reaches EOF. This option is useful for populating tables in-line in a SQL script file. For `\copy ... to stdout`, output is sent to the same place as ysqlsh command output, and the COPY count command status isn't printed (as it might be confused with a data row). To read or write ysqlsh's standard input or output, regardless of the current command source or `\o` option, write from `pstdin` or to `pstdout`.
For `\copy ... from stdin`, data rows are read from the same source that issued the command, continuing until `\.` is read or the stream reaches EOF. You can use this option to populate tables in-line in a SQL script file. For `\copy ... to stdout`, output is sent to the same place as ysqlsh command output, and the COPY count command status isn't printed (as it might be confused with a data row). To read or write ysqlsh standard input or output, regardless of the current command source or `\o` option, write from `pstdin` or to `pstdout`.

The syntax of this command is similar to that of the SQL `COPY` statement. All options other than the data source or destination are as specified for `COPY`. Because of this, special parsing rules apply to the `\copy` meta-command. Unlike most other meta-commands, the entire remainder of the line is always taken to be the arguments of `\copy`, and neither variable interpolation nor backquote expansion are performed in the arguments.

Expand Down Expand Up @@ -138,6 +138,10 @@ Lists aggregate functions, together with their return type and the data types th

Lists access methods. If *pattern* is specified, only access methods whose names match the pattern are shown. If `+` is appended to the command name, each access method is listed with its associated handler function and description.

##### \db[+] [ [pattern](#patterns) ]

Lists tablespaces. If *pattern* is specified, only tablespaces whose names match the pattern are listed. If `+` is appended to the command name, each tablespace is listed with its associated options, on-disk size, permissions, and description.

##### \dc[S+] [ [pattern](#patterns) ]

Lists conversions between character-set encodings. If *pattern* is specified, only conversions whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the `S` modifier to include system objects. If `+` is appended to the command name, each object is listed with its associated description.
Expand Down Expand Up @@ -569,7 +573,7 @@ Resets (clears) the query buffer.

##### \s [ *filename* ]

Print ysqlsh's command line history to *filename*. If filename is omitted, the history is written to the standard output (using the pager if appropriate). This command isn't available if ysqlsh was built without [Readline](../ysqlsh/#command-line-editing) support.
Print ysqlsh command line history to *filename*. If filename is omitted, the history is written to the standard output (using the pager if appropriate). This command isn't available if ysqlsh was built without [Readline](../ysqlsh/#command-line-editing) support.

##### \set [ *name* [ *value* [ ... ] ] ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ First, create tablespaces for each geographic region you wish to partition data
);
```

To view your tablespaces, you can enter the following command:

```sql
SELECT * FROM pg_tablespace;
```

## Step 2. Create table with partitions

Next, create the parent table that contains a `geo_partition` column which is used to create list-based partitions for each geographic region you want to partition data into as shown in the following diagram:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ CREATE TABLE single_zone_table (id INTEGER, field text)
TABLESPACE us_east_1a_zone_tablespace SPLIT INTO 1 TABLETS;
```

To view your tablespaces, you can enter the following command:

```sql
SELECT * FROM pg_tablespace;
```

Note from the preceding cluster configuration that the nodes in us-east-1a were 172.152.29.181, 172.152.27.126, and 172.152.22.180. By navigating to the table view in the YB-Master UI, you can verify that the tablet created for this table was indeed placed in us_east_1a_zone:

![YB-Master UI: Tablets of single_zone_table](/images/explore/tablespaces/single_zone_table_tablet_distribution.png)
Expand Down
8 changes: 6 additions & 2 deletions docs/content/stable/admin/ysqlsh-meta-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Performs a frontend (client) copy. This is an operation that runs an SQL `COPY`

When program is specified, *command* is executed by ysqlsh and the data passed from or to *command* is routed between the server and the client. Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required.

For `\copy ... from stdin`, data rows are read from the same source that issued the command, continuing until `\.` is read or the stream reaches EOF. This option is useful for populating tables in-line in a SQL script file. For `\copy ... to stdout`, output is sent to the same place as ysqlsh command output, and the COPY count command status isn't printed (as it might be confused with a data row). To read or write ysqlsh's standard input or output, regardless of the current command source or `\o` option, write from `pstdin` or to `pstdout`.
For `\copy ... from stdin`, data rows are read from the same source that issued the command, continuing until `\.` is read or the stream reaches EOF. You can use this option to populate tables in-line in a SQL script file. For `\copy ... to stdout`, output is sent to the same place as ysqlsh command output, and the COPY count command status isn't printed (as it might be confused with a data row). To read or write ysqlsh standard input or output, regardless of the current command source or `\o` option, write from `pstdin` or to `pstdout`.

The syntax of this command is similar to that of the SQL `COPY` statement. All options other than the data source or destination are as specified for `COPY`. Because of this, special parsing rules apply to the `\copy` meta-command. Unlike most other meta-commands, the entire remainder of the line is always taken to be the arguments of `\copy`, and neither variable interpolation nor backquote expansion are performed in the arguments.

Expand Down Expand Up @@ -138,6 +138,10 @@ Lists aggregate functions, together with their return type and the data types th

Lists access methods. If *pattern* is specified, only access methods whose names match the pattern are shown. If `+` is appended to the command name, each access method is listed with its associated handler function and description.

##### \db[+] [ [pattern](#patterns) ]

Lists tablespaces. If *pattern* is specified, only tablespaces whose names match the pattern are listed. If `+` is appended to the command name, each tablespace is listed with its associated options, on-disk size, permissions, and description.

##### \dc[S+] [ [pattern](#patterns) ]

Lists conversions between character-set encodings. If *pattern* is specified, only conversions whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the `S` modifier to include system objects. If `+` is appended to the command name, each object is listed with its associated description.
Expand Down Expand Up @@ -569,7 +573,7 @@ Resets (clears) the query buffer.

##### \s [ *filename* ]

Print ysqlsh's command line history to *filename*. If filename is omitted, the history is written to the standard output (using the pager if appropriate). This command isn't available if ysqlsh was built without [Readline](../ysqlsh/#command-line-editing) support.
Print ysqlsh command line history to *filename*. If filename is omitted, the history is written to the standard output (using the pager if appropriate). This command isn't available if ysqlsh was built without [Readline](../ysqlsh/#command-line-editing) support.

##### \set [ *name* [ *value* [ ... ] ] ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ First, create tablespaces for each geographic region you wish to partition data
);
```

To view your tablespaces, you can enter the following command:

```sql
SELECT * FROM pg_tablespace;
```

## Step 2. Create table with partitions

Next, create the parent table that contains a `geo_partition` column which is used to create list-based partitions for each geographic region you want to partition data into as shown in the following diagram:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ CREATE TABLE single_zone_table (id INTEGER, field text)
TABLESPACE us_east_1a_zone_tablespace SPLIT INTO 1 TABLETS;
```

To view your tablespaces, you can enter the following command:

```sql
SELECT * FROM pg_tablespace;
```

Note from the preceding cluster configuration that the nodes in us-east-1a were 172.152.29.181, 172.152.27.126, and 172.152.22.180. By navigating to the table view in the YB-Master UI, you can verify that the tablet created for this table was indeed placed in us_east_1a_zone:

![YB-Master UI: Tablets of single_zone_table](/images/explore/tablespaces/single_zone_table_tablet_distribution.png)
Expand Down

0 comments on commit 30d74fb

Please sign in to comment.