TiDB和CockroachDB都秉承Google Spanner的衣钵,分层结构和实现的依赖的存储等都有不少共同性。
由于TiDB兼容MySQL的协议,CockroachDB兼容pg协议,在国内TiDB使用的案例比较多,涵盖了TMD,CockroachDB使用
案例比较少,CockroachDB国内的使用用户有百度、京东物流等.
可能的原因:
1.pg在国内互联网领域储备的人才较少
2.pg在国内早期互联网使用的较少,缺少生产上的真实应用场景.
但是目前二者的定位可能也不一样:
TiDB定位于HTAP,github上的关键词为:
distributed-database
distributed-transactions
database
scale
mysql
htap
mysql-protocol
CockroachDB:
open source,
cloud-native SQL database
go
database
sql
distributed-database
cockroachdb
TiDB部署到生产确实需要消耗较多的高配置机器,至少需要6台;
CockroachDB 至少需要3台。
CockroachDB 强调云中立,cloud database;
TiDB目前对cloud的支持还是有限的。
截止2019年3月15日 二者在github上受欢迎的比对信息:
https://db-engines.com/en/ranking趋势比对:
具体的比对信息如下:
比对的版本以2.1.5版本为主,当然兼顾了二者Roadmap。
对比项目 | 说明 | TiDB | CockroachDB | 备注 | |
基本信息 | start year | 项目启动年月 | |||
language | 编程语言 | Golang、Rust | Goalang | ||
Github Watch | 重度关注者 | 1207 | 700 | ||
Github stars | 喜欢的人 | 17737 | 15610 | ||
Github forks | 查看代码的人 | 2544 | 1694 | ||
contributors | 代码贡献者 | 247 | 228 | ||
兼容协议 | MySQL | Postgresql | |||
开发 | 对象 | ||||
存储过程 | Stored Procedures | No | planning | ||
自定义函数 | custom function | No | planning | ||
触发器 | trigger | No | planning | ||
视图 | view | Yes | Yes | ||
序列 | sequence | No | Yes | ||
游标 | cursor | No | No | ||
任务 | Job or event | No | Yes | ||
索引 | Index | Yes | Yes | ||
表 | table | Yes | Yes | ||
临时表 | temporary table | No | No | ||
Data type(数据类型) | |||||
int | Yes | Yes | |||
FLOAT,REAL | Yes | Yes | |||
BOOLEAN | Yes | Yes | |||
DECIMAL,NUMERIC | Yes | Yes | |||
NULL | Yes | Yes | |||
BYTES | No | Yes | |||
STRING | Yes | Yes | |||
AUTO INCREMENT | Yes | Yes | |||
ARRAY | No | Yes | |||
UUID | Yes | Yes | |||
TIME | Yes | Yes | |||
SET ENUM | Yes | Yes | |||
INET | No | Yes | |||
generation Key | 生成列 | Yes | Yes | ||
UNSIGNED INT | Yes | No(Not plan) | |||
Constraints(约束) | |||||
Not null | 非空约束 | Yes | Yes | ||
unique | 唯一约束 | Yes | Yes | ||
Primary key | 主键 | Yes | Yes | ||
check | 检查约束 | No | Yes | ||
Foreign Key | 外键 | No | Yes | ||
Default Value | 默认值 | Yes | Yes | ||
Transactions(事务) | |||||
Transactions(ACID) | Yes | Yes | |||
BEGIN | Yes | Yes | |||
COMMIT | Yes | Yes | |||
ROLLBACK | Yes | Yes | |||
SAVEPOINT | Yes | Yes | |||
Index(索引) | |||||
indexes | 普通索引 | Yes | Yes | ||
Multi-column indexes | 多列索引 | Yes | Yes | ||
Covering indexes | 覆盖索引 | Yes | Yes | ||
Inverted indexes | 反转索引 | NO | Yes | ||
Multiple indexes per query | 每个查询多个索引 | Yes | planning | ||
Full-text indexes | 全文索引 | NO | planning | ||
Prefix/Expression Indexes | 前缀索引/表达式索引 | NO | Potential | ||
Geospatial indexes | 地理信息索引 | NO | Potential | ||
Hash indexes | 哈希索引 | NO | No | ||
Partial indexes | 部分索引 | NO | NO | ||
clauses(语句) | |||||
Common table expression | with 语句 | Planning | Yes(Partial) | ||
Windows functions | 窗口函数 | Planning | Yes | ||
regular expression | 正则表达式 | planning | Yes | ||
JSON | Yes(Partial) | Yes | |||
XML | NO | NO | |||
SELECT INTO | Yes(Alternative) | Yes(Alternative) | |||
CTAS | NO | Yes | |||
MERGE | Yes | Yes(upset) | |||
delete | Yes | Yes | |||
insert | Yes | Yes | |||
update | Yes | Yes | |||
truncate | Yes | Yes | |||
LIMIT | Yes | Yes | |||
LIMIT with offset | Yes | Yes | |||
RETURNING | No | Yes | |||
partition table(分区表) | |||||
range | Yes | Yes(Enterprise Edtion) | |||
list | No | Yes(Enterprise Edtion) | |||
Hash | Yes | Yes(Enterprise Edtion) | |||
subpartition | No | Yes(Enterprise Edtion) | |||
事务隔离级别 | SI | SSI(Serializable Snapshot Isolation) | |||
表级别锁 | 乐观锁 | 乐观锁 | |||
行级别锁 | 乐观锁 | 乐观锁 | |||
管理 | user | 用户 | Yes | Yes | |
role | 角色 | NO | Yes(Enterprise Edtion) | ||
grant | 授权 | Yes | Yes | ||
revoke | 撤销 | Yes | Yes | ||
statistics | 统计信息 | Yes | Yes | ||
explain | 执行计划 | Yes | Yes | ||
backup Recovery | 备份恢复 | Yes | Yes | ||
Query management stmt | 查询进程管理 | Yes(Kill tidb PID) | Yes(cancel query) | ||
Transaction management | 事务管理 | Yes | Yes | ||
Audit | 审计 | planning | Yes(EXPERIMENTAL) | ||
部署 | windows | No | Yes | ||
Linux | Yes | Yes | |||
Mac | No | Yes | |||
docker | Yes | cloud-neutral | |||
Kubernetes | Yes | Yes | |||
Mesosphere DC/OS | Yes | ||||
Rolling update | 滚动升级 | Yes | Yes | ||
manual deployment | 手动部署 | Yes(不推荐) | Yes | ||
Orchestration | 容器编排部署 | Yes(试验性质) | Yes | ||
Docker | Docker | Yes | Yes | ||
monitor and alert | 监控告警 | Yes | Yes | prometheus alertmanager | |
Production machine | 最小的生产主机 | 3台 | 6台 | ||
架构 | 水平扩展 | Scale out | |||
高可用 | HA | ||||
异地多活 | geo-distributed | ||||
数据复制 | Data replication | ||||
自动负载均衡 | |||||
容错与恢复 | |||||
数据迁移 | Data Migration | Yes(MySQL,CSV) | Yes(MySQL,pg,CSV) | ||
扩展 | 对接kafka | TiDB-binlog | CDC | ||
回撤数据 | MySQL | NO | |||
复制 | TiDB | NO | |||
第三方支持 | |||||
主流编程语言接口(C\C++\Java \Python\Go\NodeJS) | Yes | Yes |
https://pingcap.com/docs/ROADMAP/参考:
https://github.com/cockroachdb/cockroach/wiki/Roadmap
https://pingcap.com/docs-cn/v2.1/ROADMAP/#tidb
https://www.cockroachlabs.com/docs/stable/sql-feature-support.html
https://github.com/cockroachdb/cockroach/blob/master/docs/design.md