Skip to content

Commit

Permalink
[Doc] index page for query acceleration (#55504)
Browse files Browse the repository at this point in the history
(cherry picked from commit ff432b6)

# Conflicts:
#	docs/en/table_design/table_types/primary_key_table.md
#	docs/en/using_starrocks/_category_.yml
#	docs/zh/table_design/table_types/primary_key_table.md
  • Loading branch information
DanRoscigno authored and mergify[bot] committed Jan 28, 2025
1 parent 2b0409d commit f66c18c
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 12 deletions.
18 changes: 9 additions & 9 deletions docs/docusaurus/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@
"type": "category",
"label": "Query Acceleration",
"link": {
"type": "doc",
"id": "cover_pages/query_acceleration"
},
"items": [
{
"type": "autogenerated",
"dirName": "using_starrocks"
}
]
"type": "doc",
"id": "using_starrocks/using_starrocks"
},
"items": [
{
"type": "autogenerated",
"dirName": "administration/management/resource_management"
}
]
},
{
"type": "category",
Expand Down
34 changes: 34 additions & 0 deletions docs/en/table_design/table_types/primary_key_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,38 @@ PROPERTIES("replication_num" = "3",

After table creation, you can run load jobs to load data into the Primary Key table. For more information about supported loading methods, see [Overview of data loading](../../loading/Loading_intro.md).

<<<<<<< HEAD
If you need to update data in the Primary Key table, you can [run a load job](../../loading/Load_to_Primary_Key_tables.md) or execute a DML statement ([UPDATE](../../sql-reference/sql-statements/table_bucket_part_index/UPDATE.md) or [DELETE](../../sql-reference/sql-statements/table_bucket_part_index/DELETE.md)). Also, these update operations guarantee atomicity.
=======
![pk5](../../_assets/table_design/pk5.png)

- The table is a flat table that is composed of hundreds or thousands of columns. The Primary Key comprises only a small portion of the table data and consumes only a small amount of memory. For example, a user status or profile table consists of a large number of columns but only tens to hundreds of millions of users. In this situation, the amount of memory consumed by the primary key is controllable.

As shown in the following figure, the table contains only a few rows, and the Primary Key of the table comprises only a small portion of the table.
![pk6](../../_assets/table_design/pk6.png)

</TabItem>

</Tabs>

### Sort key

From v3.0, the Primary Key table decouples the sort key from the Primary Key. The sort key is composed of the columns defined in `ORDER BY`, and can consist of any combination of columns, as long as the data type of the columns meets the requirement of the sort key.

During data loading, the data is stored after being sorted according to the sort key. The sort key is also used to build the Prefix index to accelerate queries. It is recommended to [design the sort key appropriately to form the Prefix index that can accelerate queries](../indexes/Prefix_index_sort_key.md#how-to-design-the-sort-key-appropriately-to-form-the-prefix-index-that-can-accelerate-queries).

:::info

- If the sort key is specified, the Prefix index is built based on the sort key. If no sorti key is specified,the Prefix index are built based on the Primary Key.
- After table creation, you can use `ALTER TABLE ... ORDER BY ...` to change the sort key. Deleting the sort key is not supported, and modifying the data types of sort columns is not supported.

:::

## What's more

- To load data into the table created, you can refer to [Loading overview](../../loading/Loading_intro.md) to choose an appropriate load options.
- If you need to change data in the Primary Key table, you can refer to [change data through loading](../../loading/Load_to_Primary_Key_tables.md) or use DML ([INSERT](../../sql-reference/sql-statements/loading_unloading/INSERT.md), [UPDATE](../../sql-reference/sql-statements/table_bucket_part_index/UPDATE.md), and [DELETE](../../sql-reference/sql-statements/table_bucket_part_index/DELETE.md)).
- If you want to further accelerate queries, you can refer to [Query Acceleration](../../using_starrocks/using_starrocks.mdx).
- If you need to modify the table schema, you can refer to [ALTER TABLE](../../sql-reference/sql-statements/Resource/ALTER_RESOURCE.md).
- An [AUTO_INCREMENT](../../sql-reference/sql-statements/generated_columns.md) column can be used as the Primary Key.
>>>>>>> ff432b6418 ([Doc] index page for query acceleration (#55504))
5 changes: 5 additions & 0 deletions docs/en/using_starrocks/_category_.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<<<<<<< HEAD
position: 50 # float position is supported
label: 'Indexes'
=======
position: 60 # float position is supported
label: 'Query Acceleration'
>>>>>>> ff432b6418 ([Doc] index page for query acceleration (#55504))
collapsible: true
collapsed: true
link:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
displayed_sidebar: docs
keywords: ['shitu']
---

# 查询加速
# Query Acceleration

import DocCardList from '@theme/DocCardList';

Expand Down
29 changes: 29 additions & 0 deletions docs/zh/table_design/table_types/primary_key_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,34 @@ PROPERTIES (

## 下一步

<<<<<<< HEAD
建表完成后,您可以创建导入作业,导入数据至表中。具体导入方式,请参见[导入总览](../../loading/Loading_intro.md)
如果需要更新主键模型表的数据,您可以通过[导入](../../loading/Load_to_Primary_Key_tables.md)或执行 DML 语句([UPDATE](../../sql-reference/sql-statements/table_bucket_part_index/UPDATE.md)[DELETE](../../sql-reference/sql-statements/table_bucket_part_index/DELETE.md)实现,并且更新操作是原子性的。
=======
- **大宽表**(数百到数千列)。主键只占整个数据的很小一部分,其内存开销比较低。比如用户状态和画像表,虽然列非常多,但总的用户数不大(千万至亿级别),主键索引内存占用相对可控。 如图所示,大宽表中主键只占一小部分,且数据行数不多。
![pk6](../../_assets/table_design/pk6.png)

</TabItem>
</Tabs>

### 排序键

自 3.0 起,主键表解耦了排序键和主键,排序键由 `ORDER BY` 定义的排序列组成,可以为任意列的排列组合,只要列的数据类型满足排序键的要求。

导入数据时数据按照排序键排序后存储,并且排序键还用于构建前缀索引,能够加速查询。建议您[设计合理排序键,以便查询利用前缀索引加速](../indexes/Prefix_index_sort_key.md#如何设计合理排序键以便查询利用前缀索引加速)

:::info

- 如果指定了排序键,就根据排序键构建前缀索引;如果没指定排序键,就根据主键构建前缀索引。
- 建表后支持通过 `ALTER TABLE ... ORDER BY ...` 修改排序键。不支持删除排序键,不支持修改排序列的数据类型。

:::

## 更多信息

- 建表后导入数据,您可以参考[导入概览](../../loading/Loading_intro.md)选择合适的导入方式。
- 如果需要对主键表中数据进行变更,则可以参考 [通过导入实现数据变更](../../loading/Load_to_Primary_Key_tables.md) 或者 DML 语句([INSERT](../../sql-reference/sql-statements/loading_unloading/INSERT.md)[UPDATE](../../sql-reference/sql-statements/table_bucket_part_index/UPDATE.md)[DELETE](../../sql-reference/sql-statements/table_bucket_part_index/DELETE.md))。
- 如果您需要进一步加速查询,则可以参考[查询加速](../../using_starrocks/using_starrocks.mdx)
- 如果需要修改表结构,则可以参考 [ALTER TABLE](../../sql-reference/sql-statements/Resource/ALTER_RESOURCE.md)
- [自增列](../../sql-reference/sql-statements/generated_columns.md)可作为生成主键。
>>>>>>> ff432b6418 ([Doc] index page for query acceleration (#55504))
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
displayed_sidebar: docs
---

#
# 查询加速

import DocCardList from '@theme/DocCardList';

<DocCardList />

0 comments on commit f66c18c

Please sign in to comment.