Which of the following is the main reason to use table partitioning in PostgreSQL?
Think about how partitioning helps with large datasets and query speed.
Partitioning helps by dividing a large table into smaller pieces, so queries can scan only the needed partitions, improving performance.
Given a table sales partitioned by range on sale_date, which query will return sales only from 2023?
SELECT * FROM sales WHERE sale_date >= '2023-01-01' AND sale_date < '2024-01-01';
Check the date range in the WHERE clause.
The query filters sales between 2023-01-01 (inclusive) and 2024-01-01 (exclusive), so only 2023 sales are returned.
Which of the following CREATE TABLE statements correctly creates a list partition for a table orders partitioned by region?
Look for the correct syntax to specify list partition values.
The correct syntax uses FOR VALUES IN ('value') to define list partitions.
Which is the best practice when choosing a partition key for a large table?
Think about how partition pruning works with query filters.
Choosing a column with many distinct values and often used in filters helps queries scan fewer partitions, improving performance.
Consider a partitioned table events partitioned by LIST on event_type. The query SELECT * FROM events WHERE event_type = 'login'; returns no rows, but data exists. What is the most likely cause?
Think about how partitions must be created and attached for data to be found.
If the partition for a specific list value is missing or not attached, queries filtering on that value return no rows even if data exists elsewhere.