Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Jan 17, 2022
1 parent 1b079e9 commit d665e0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Gorm Sharding

[![GoDoc](https://godoc.org/github.com/longbridge/gorm-sharding?status.svg)](https://godoc.org/github.com/longbridge/gorm-sharding)
[![Go](https://github.com/longbridgeapp/gorm-sharding/actions/workflows/go.yml/badge.svg)](https://github.com/longbridgeapp/gorm-sharding/actions/workflows/go.yml)
[![GoDoc](https://godoc.org/github.com/longbridgeapp/gorm-sharding?status.svg)](https://godoc.org/github.com/longbridgeapp/gorm-sharding)

English | [简体中文](./README.zh-CN.md)

Gorm Sharding splits large tables into smaller ones to speed up access.
Gorm Sharding plugin using SQL parser and replace for splits large tables into smaller ones, redirects Query into sharding tables. Give you a high performance database access.

Assume we have an order table with 100 million rows, we can divide it into 1000 smaller ones, so the read and write operation will faster than operate the original table.
Gorm Sharding 是一个业务污染小,高性能的数据库分表方案。通过 SQL 解析和替换,实现分表逻辑,让查询正确的根据规则执行到分表里面。

![Example Scenario](./images/example-scenario.svg)

Expand All @@ -15,6 +16,7 @@ Assume we have an order table with 100 million rows, we can divide it into 1000
- Non-intrusive design. Load the plugin, specify the config, and all done.
- Lighting-fast. No network based middlewares, as fast as Go.
- Multiple database support. PostgreSQL tested, MySQL and SQLite is coming.
- Allows you custom the Primary Key generator (Sequence, UUID, Snowflake ...).

## Install

Expand Down Expand Up @@ -49,7 +51,9 @@ middleware := sharding.Register(map[string]sharding.Resolver{
return fmt.Sprintf("_%02d", keygen.TableIdx(id))
},
PrimaryKeyGenerate: func(tableIdx int64) int64 {
return keygen.Next(tableIdx)
keygen.Snowflake()
keygen.UUID(),
keygen.Sequence("orders_id_seq"),
}
},
})
Expand Down
12 changes: 6 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

[English](./README.md) | 简体中文

Gorm Sharding 将大表拆分成多个小表来加速访问。

假设有一个一亿行的订单表,我们可以将它拆分成一千个小表,这样读写操作就会比操作原始表快很多。
Gorm Sharding 是一个业务污染小,高性能的数据库分表方案。通过 SQL 解析和替换,实现分表逻辑,让查询正确的根据规则执行到分表里面。

![场景示例](./images/example-scenario.svg)

## 特色

- 非侵入式设计。加载插件,指定配置,完成。
- 快。没有网络中间件,跟 Go 一样快。
- 多数据库支持。PostgreSQL 已测试,MySQL 和 SQLite 进行中。
- 非侵入式设计,业务污染极小。
- 基于 Gorm Plugin 设计,无中间件服务,基本无额外的性能开销。
- 多种数据库支持:PostgreSQL 已测试,MySQL 和 SQLite 进行中。
- 配置简单易懂。
- 支持自定义主键生成方式。

## 安装

Expand Down

0 comments on commit d665e0d

Please sign in to comment.