0Pricing
Advanced PostgreSQL: Indexing, Partitioning, Replication · 강의

하위 파티셔닝 기법

더 세밀하게 데이터를 구성하도록 하위 파티셔닝을 구현하여 여러 파티셔닝 방법을 결합합니다.

하위 파티셔닝 기법은(는) CoddyKit의 무료 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Advanced PostgreSQL: Indexing, Partitioning, Replication 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Deeper Data Organization

Welcome! In this lesson, we'll explore sub-partitioning, an advanced technique to combine different partitioning methods in PostgreSQL.

It allows you to organize your data with even finer granularity, creating a powerful hierarchical structure for very large tables.

Why Use Sub-Partitioning?

Sub-partitioning offers several key advantages for managing and querying massive datasets:

  • Finer Granularity: Break down large partitions into smaller, more manageable units.
  • Targeted Management: Easier to perform operations (e.g., attach, detach, archive) on specific data subsets.
  • Improved Query Performance: The database can prune even more irrelevant data blocks, significantly speeding up queries on specific sub-sections.

How Nested Partitions Work

With sub-partitioning, you define a primary partitioning strategy for your main table. Then, for each individual partition of that main table, you define a secondary partitioning strategy.

Think of it as partitioning a table by year, and then partitioning each year's data further by region. It's a 'partition of a partition' concept.

Strategy: Range by Date, List by Region

A common and effective sub-partitioning pattern is to first partition a table by a date range (e.g., year or quarter), and then sub-partition each date range by a list of discrete values (e.g., region, department, status).

This is ideal for time-series data that also has important categorical attributes, allowing you to quickly filter by both.

Code: Main Table (Range)

Let's create an orders table. This will be our top-level parent, partitioned by order_date using RANGE partitioning.

CREATE TABLE orders (
    order_id INT,
    order_date DATE,
    region TEXT,
    amount DECIMAL
) PARTITION BY RANGE (order_date);

Code: Level 1 Partition (Range & List Parent)

Now, we create a partition for the year 2023. Crucially, we add PARTITION BY LIST (region) to this partition definition.

This makes orders_2023 itself a parent table, ready for its own sub-partitions.

CREATE TABLE orders_2023
PARTITION OF orders
FOR VALUES FROM ('2023-01-01') TO ('2024-01-01')
PARTITION BY LIST (region);

Code: Level 2 Sub-Partitions & Insert

Finally, we create the actual sub-partitions for specific regions within the orders_2023 partition. Data for 'North' goes into orders_2023_north, etc. We'll also insert some data to see it in action.

CREATE TABLE orders_2023_north
PARTITION OF orders_2023
FOR VALUES IN ('North');

CREATE TABLE orders_2023_south
PARTITION OF orders_2023
FOR VALUES IN ('South');

INSERT INTO orders VALUES
(1, '2023-03-15', 'North', 150.00),
(2, '2023-07-22', 'South', 200.50),
(3, '2023-11-01', 'North', 75.25);

SELECT tableoid::regclass, * FROM orders ORDER BY order_id;

Strategy: List by Category, Range by Year

You can also reverse the strategy: partition first by a list of categories (e.g., 'Electronics', 'Books'), and then sub-partition each category by a date range (e.g., release year).

This is useful when your primary access pattern is by category, and then you need to filter within categories by time.

Quick Check: Sub-Partitioning

Sub-partitioning offers powerful ways to organize data. Which of the following statements correctly describe its characteristics or benefits?

Recap & Next Steps

You've now learned about PostgreSQL sub-partitioning!

  • We saw how to combine RANGE and LIST partitioning to create deeply organized tables.
  • This technique provides finer data granularity and can significantly boost query performance by enabling more precise partition pruning.
  • Understanding sub-partitioning is crucial for managing extremely large and complex datasets effectively.

Next, we'll dive into managing partitioned tables, including adding, dropping, and altering partitions efficiently.

자주 묻는 질문

“하위 파티셔닝 기법” 강의는 무료인가요?

네 — “하위 파티셔닝 기법” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의 전체를 잠금 해제할 수 있습니다. Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 총 4개의 강의가 포함되어 있습니다.

“하위 파티셔닝 기법”에서 뭘 배우나요?

더 세밀하게 데이터를 구성하도록 하위 파티셔닝을 구현하여 여러 파티셔닝 방법을 결합합니다. 브라우저에서 직접 실행하는 실습 코드로 Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Advanced PostgreSQL: Indexing, Partitioning, Replication은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“하위 파티셔닝 기법” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 분산을 위한 해시 파티셔닝
  2. 하위 파티셔닝 기법
  3. 파티션 테이블 관리
  4. 시간 기준 범위 파티셔닝
← Advanced PostgreSQL: Indexing, Partitioning, Replication(으)로 돌아가기