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

未关闭
#1,540 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 10 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
mysql
领域
databases

调研方向

首先检查 gh-ost 现有的主键和分区 MySQL 表处理方式;该 issue 未指定文件、测试或入口点。确定复合键支持的范围和设计,然后定义涵盖分区表示例以及成功执行在线 schema 迁移的测试。

由索引模型根据 Issue 内容生成。

描述

enhancement

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

主要语言
Go
星标
13.6k
派生
1.4k
平均合并
9 天 19 小时
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/gh-ost 的其他 Issue

查看 github/gh-ost 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。