Query Performance in Apache Cloudberry
Apache Cloudberry dynamically eliminates irrelevant partitions in a table and optimally allocates memory for different operators in a query.These enhancements scan less data for a query, accelerate query processing, and support more concurrency.
-
Dynamic partition elimination
In Apache Cloudberry, values available only when a query runs are used to dynamically prune partitions, which improves query processing speed. Enable or deactivate dynamic partition elimination by setting the server configuration parameter
gp_dynamic_partition_pruning
toON
orOFF
; it isON
by default. -
Memory optimizations
Apache Cloudberry allocates memory optimally for different operators in a query and frees and re-allocates memory during the stages of processing a query.
Apache Cloudberry uses GPORCA by default. GPORCA extends the planning and optimization capabilities of the Postgres optimizer.
📄️ 更新统计信息
要获得良好的查询性能,准确的统计信息准确十分重要。通过使用 ANALYZE 语句更新统计信息,可以使查询优化器生成最优的查询计划。Apache Cloudberry 对表进行分析时,相关的数据信息被存储在系统目录表中。如果存储的信息过时了,查询优化器可能会生成低效的查询计划。
📄️ 在 AO 表上使用唯一索引
自 v1.5.0 版本起,你可以在 Apache Cloudberry 的 Append-Optimized (AO) 或 AOCS 表上添加唯一索引。有了唯一索引,Apache Cloudberry 会在将数据插入到 AO 表时,强制检查唯一性约束,从而保证数据的唯一性,同时能够与优化器一起优化特定的查询,从而提高数据库的查询性能。但这也带来的一定的开销用于维护唯一索引,尤其是在插入数据时。