Recall & Review
beginner
What is hash partitioning in a database?
Hash partitioning is a method of dividing a table into smaller parts (partitions) based on a hash function applied to a column's values. This helps distribute data evenly across partitions.
Click to reveal answer
beginner
How does hash partitioning help with data distribution?
Hash partitioning uses a hash function to assign rows to partitions, ensuring data is spread evenly. This improves query performance and balances storage and workload.
Click to reveal answer
intermediate
In PostgreSQL, how do you create a hash partitioned table?
You create a partitioned table with PARTITION BY HASH(column_name), then create partitions with FOR VALUES WITH (MODULUS n, REMAINDER r) to specify which rows go where.
Click to reveal answer
intermediate
What is the role of MODULUS and REMAINDER in PostgreSQL hash partitions?
MODULUS defines the total number of partitions, and REMAINDER specifies which partition a row belongs to based on the hash value modulo MODULUS.
Click to reveal answer
intermediate
Why might hash partitioning be preferred over range partitioning?
Hash partitioning evenly distributes data regardless of value ranges, which is useful when data is uniformly accessed or when range boundaries are hard to define.
Click to reveal answer
What does hash partitioning use to assign rows to partitions?
✗ Incorrect
Hash partitioning uses a hash function applied to a column's value to decide which partition a row belongs to.
In PostgreSQL, which clause specifies hash partitioning when creating a table?
✗ Incorrect
The clause PARTITION BY HASH(column_name) tells PostgreSQL to use hash partitioning on that column.
What does the MODULUS value represent in PostgreSQL hash partitions?
✗ Incorrect
MODULUS defines how many partitions the table is divided into.
Which of these is a benefit of hash partitioning?
✗ Incorrect
Hash partitioning helps spread data evenly across partitions.
If you want to partition a table into 4 parts using hash partitioning, what should MODULUS be set to?
✗ Incorrect
MODULUS should be set to the number of partitions, so 4 for four partitions.
Explain how hash partitioning works and why it is useful for distributing data.
Think about how a hash function assigns rows to different partitions.
You got /4 concepts.
Describe the steps to create a hash partitioned table in PostgreSQL and how partitions are defined.
Focus on the syntax and meaning of MODULUS and REMAINDER.
You got /4 concepts.