Skip to content

Feature Request: Support for Multi-Column Primary Keys with Partitioned Tables #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
freeman-buzzvil opened this issue Apr 28, 2025 · 0 comments

Comments

@freeman-buzzvil
Copy link

Hi gh-ost team,

Thank you for maintaining such a powerful and reliable tool for online schema migrations. gh-ost has been a core part of our database operations for minimizing downtime during schema changes.

However, we are currently facing a limitation: gh-ost does not support tables with multi-column (composite) primary keys.
In many production environments, especially those using normalized schemas or advanced partitioning strategies, composite primary keys are a necessity rather than an option.

Let me give you a real-world example from our company.
We manage large, partitioned tables for statistical data. These tables have heavy write loads and massive storage volumes. Here is a simplified version of one of them:

CREATE TABLE partitioned_table (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `data_at` datetime NOT NULL,
  ...
  PRIMARY KEY (`id`, `data_at`)
) ENGINE=InnoDB DEFAULT CHARSET=ascii
/*!50500 PARTITION BY RANGE COLUMNS(data_at)
(PARTITION m2501 VALUES LESS THAN ('2025-02-01') ENGINE = InnoDB,
 PARTITION m2502 VALUES LESS THAN ('2025-03-01') ENGINE = InnoDB,
 PARTITION m2503 VALUES LESS THAN ('2025-04-01') ENGINE = InnoDB,
 PARTITION m2504 VALUES LESS THAN ('2025-05-01') ENGINE = InnoDB,
 PARTITION m2505 VALUES LESS THAN ('2025-06-01') ENGINE = InnoDB,
 PARTITION mMAX VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB) */

Because of the composite primary key (id, data_at) and the size of the table, using gh-ost would be ideal for safely applying schema changes without significant locking or replication lag.

Unfortunately, the current lack of multi-column primary key support forces us to use alternative tools like pt-online-schema-change for these critical tables, even though gh-ost would be a far better fit for our operational standards.

Supporting multi-column primary keys would greatly extend gh-ost’s usability in real-world, high-load, and partitioned environments like ours.
Even partial or experimental support would already make a big difference.

Is there any plan or consideration to support this in the future?
We would be more than happy to contribute, test, or assist in any way if this feature could be prioritized.

Thanks again for your outstanding work and for considering this request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant