DBmaint Module
This page provides an overview of the DBmaint module, which includes utility functions for maintaining splayed and partitioned KDB-X database tables.
The DBmaint module is a specialized utility suite within the KDB-X ecosystem designed for the structural maintenance and evolution of partitioned kdb+ databases. It streamlines complex administrative tasks such as schema changes, column transformations, and attribute management by automating the application of these changes across all database partitions at once. By providing a standardized interface for modifying persisted data, it reduces manual intervention and reduces the risk of inconsistencies that can arise from direct filesystem operations.
Key features
- Schema Evolution: Easily add (
addCol), delete (delCol), rename (renameCol), or reorder (reorderCols) columns across all partitions. - Data Transformation: Apply unary functions to entire columns (
fnCol) or cast columns to different types (castCol) globally. - Table Management: Support for adding new tables (
addTab), renaming existing ones (renameTab), or removing them entirely (delTab). - Attribute Control: Simplified commands to apply or remove kdb+ performance attributes like parted (
p), sorted (s), unique (u), or grouped (g) usingsetAttrandrmAttr.
Typical use cases
- Database Refactoring: Renaming legacy columns or change type of a column to meet new business requirements.
- Performance Tuning: Assigning the "parted" attribute to the
symcolumn across years of historical data to optimize on-disk lookups. - Data Correction: Using
fnColto fix data entry errors across specific date ranges or the entire history. - Schema Synchronization: Using
addMissingColsto ensure that older partitions contain the same columns as the most recent data capture, preventing "missing column" errors during cross-partition queries.
For a full list of available functions and examples, refer to the DBmaint documentation on GitHub.