This is an automated email from the ASF dual-hosted git repository.

djwang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry-site.git


The following commit(s) were added to refs/heads/main by this push:
     new 4e751b6e Doc: add columnar compression doc (#180)
4e751b6e is described below

commit 4e751b6ede2278eff87bc77484f5ea9d0e27db43
Author: TomShawn <[email protected]>
AuthorDate: Tue Nov 26 11:36:40 2024 +0800

    Doc: add columnar compression doc (#180)
---
 docs/performance/use-columnar-compression.md       | 87 ++++++++++++++++++++++
 .../performance/use-columnar-compression.md        | 87 ++++++++++++++++++++++
 sidebars.ts                                        |  2 +-
 3 files changed, 175 insertions(+), 1 deletion(-)

diff --git a/docs/performance/use-columnar-compression.md 
b/docs/performance/use-columnar-compression.md
new file mode 100644
index 00000000..97082673
--- /dev/null
+++ b/docs/performance/use-columnar-compression.md
@@ -0,0 +1,87 @@
+---
+title: Use Column-Level Compression
+---
+
+# Use Column-Level Compression
+
+Apache Cloudberry supports column-level compression, which reduces storage 
space by compressing specific columns. In some cases, it can also improve query 
performance, especially when processing large-scale data.
+
+## User scenarios
+
+- **Storage optimization**: Reduces disk space usage for storage-intensive 
applications.
+- **Performance improvement**: Smaller compressed data blocks reduce I/O costs 
in columnar query scenarios.
+- **High-frequency data analysis**: Lowers data access costs in large-scale 
data analysis.
+
+## Example usage
+
+The following is a simple example demonstrating how column-level compression 
can make a difference in Apache Cloudberry.
+
+1. Create a table without column-level compression.
+
+    ```sql
+    CREATE TABLE no_column_compression (
+        id serial PRIMARY KEY,
+        data1 text,
+        data2 text
+    );
+    ```
+
+2. Create a table with column-level compression.
+
+    ```sql
+    CREATE TABLE column_compression (
+        id serial PRIMARY KEY,
+        data1 text ENCODING (compresstype=zlib, compresslevel=5),
+        data2 text
+    )
+    WITH (
+        appendoptimized=true,
+        orientation=column
+    );
+    ```
+
+3. Insert data into the table without column-level compression.
+
+    ```sql
+    INSERT INTO no_column_compression (data1, data2)
+    SELECT repeat(md5(random()::text), 10), repeat(md5(random()::text), 10)
+    FROM generate_series(1, 100000);
+    ```
+
+4. Insert data into the table with column-level compression.
+
+    ```sql
+    INSERT INTO column_compression (data1, data2)
+    SELECT repeat(md5(random()::text), 10), repeat(md5(random()::text), 10)
+    FROM generate_series(1, 100000);
+    ```
+
+5. Check the storage size of the table without column-level compression.
+
+    ```sql
+    SELECT pg_size_pretty(pg_total_relation_size('no_column_compression')) AS 
no_column_compression_size;
+    ```
+
+    Example result:
+
+    ```sql
+    no_column_compression_size
+    ---------------------------
+    69 MB
+    ```
+
+6. Check the storage size of the table with column-level compression.
+
+    ```sql
+    SELECT pg_size_pretty(pg_total_relation_size('column_compression')) AS 
column_compression_size;
+    ```
+
+    Example result:
+
+    ```sql
+    column_compression_size
+    ------------------------
+    36 MB
+    ```
+
+Compressed tables use significantly less storage space compared to 
uncompressed tables. In this example, the table with column-level compression 
reduced storage usage by nearly 50%.
diff --git 
a/i18n/zh/docusaurus-plugin-content-docs/current/performance/use-columnar-compression.md
 
b/i18n/zh/docusaurus-plugin-content-docs/current/performance/use-columnar-compression.md
new file mode 100644
index 00000000..a2cc7948
--- /dev/null
+++ 
b/i18n/zh/docusaurus-plugin-content-docs/current/performance/use-columnar-compression.md
@@ -0,0 +1,87 @@
+---
+title: 使用列级压缩
+---
+
+# 使用列级压缩
+
+Apache Cloudberry 
支持列级压缩功能,通过对指定列进行数据压缩,可以显著减少存储空间的占用。在某些情况下,列级压缩还能优化查询性能,特别是在处理大规模数据时。
+
+## 使用场景
+
+- **存储优化**:对于存储密集型的应用,列级压缩能够有效减少磁盘空间使用。
+- **性能提升**:在列存储的查询场景下,压缩后的数据块更小,可以减少 I/O 开销。
+- **高频数据分析**:在大规模数据分析场景中,列级压缩可以降低读取数据的成本。
+
+## 使用示例
+
+以下是一个简单的列级压缩功能示例,展示了在 Apache Cloudberry 中使用列级压缩的效果。
+
+1. 创建不使用列级压缩的表。
+
+    ```sql
+    CREATE TABLE no_column_compression (
+        id serial PRIMARY KEY,
+        data1 text,
+        data2 text
+    );
+    ```
+
+2. 创建使用列级压缩的表。
+
+    ```sql
+    CREATE TABLE column_compression (
+        id serial PRIMARY KEY,
+        data1 text ENCODING (compresstype=zlib, compresslevel=5),
+        data2 text
+    )
+    WITH (
+        appendoptimized=true,
+        orientation=column
+    );
+    ```
+
+3. 插入数据到不使用列级压缩的表。
+
+    ```sql
+    INSERT INTO no_column_compression (data1, data2)
+    SELECT repeat(md5(random()::text), 10), repeat(md5(random()::text), 10)
+    FROM generate_series(1, 100000);
+    ```
+
+4. 插入数据到使用列级压缩的表。
+
+    ```sql
+    INSERT INTO column_compression (data1, data2)
+    SELECT repeat(md5(random()::text), 10), repeat(md5(random()::text), 10)
+    FROM generate_series(1, 100000);
+    ```
+
+5. 查看不使用列级压缩的表的存储空间。
+
+    ```sql
+    SELECT pg_size_pretty(pg_total_relation_size('no_column_compression')) AS 
no_column_compression_size;
+    ```
+
+    示例结果:
+
+    ```sql
+    no_column_compression_size
+    ---------------------------
+    69 MB
+    ```
+
+6. 查看使用列级压缩的表的存储空间。
+
+    ```sql
+    SELECT pg_size_pretty(pg_total_relation_size('column_compression')) AS 
column_compression_size;
+    ```
+
+    示例结果:
+
+    ```sql
+    column_compression_size
+    ------------------------
+    36 MB
+    ```
+
+压缩后的表占用的存储空间明显小于未压缩的表。在本示例中,使用列级压缩的表减少了接近 50% 的存储空间。
\ No newline at end of file
diff --git a/sidebars.ts b/sidebars.ts
index ae979baa..181d3c7d 100644
--- a/sidebars.ts
+++ b/sidebars.ts
@@ -78,7 +78,7 @@ const sidebars: SidebarsConfig = {
         type: "doc",
         id: 'performance/index',
       },
-       items: ['performance/update-stats-using-analyze', 
'performance/use-unique-index-on-ao-tables', 
'performance/use-auto-materialized-view-to-answer-queries', 
'performance/use-incremental-materialized-view', 
'performance/parallel-create-ao-refresh-mv', 
'performance/parallel-query-execution', 
'performance/use-aggre-pushdown-to-speed-up-queries', 
'performance/use-index-scan-on-ao-tables', 
'performance/use-runtimefilter-to-optimize-queries']
+       items: ['performance/update-stats-using-analyze', 
'performance/use-unique-index-on-ao-tables', 
'performance/use-auto-materialized-view-to-answer-queries', 
'performance/use-incremental-materialized-view', 
'performance/parallel-create-ao-refresh-mv', 
'performance/parallel-query-execution', 
'performance/use-aggre-pushdown-to-speed-up-queries', 
'performance/use-index-scan-on-ao-tables', 
'performance/use-runtimefilter-to-optimize-queries','performance/use-columnar-compression']
      },
 
      {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to