diff --git a/docs/query.md b/docs/query.md index d463e69..b3eab5f 100644 --- a/docs/query.md +++ b/docs/query.md @@ -54,16 +54,16 @@ end subgraph database [Database] - posts_other[("orders_0, orders_1 ... orders_3")] - posts_4[(orders_4)] - posts_last[("orders_5 ... orders_15")] + orders_other[("orders_0, orders_1 ... orders_3")] + orders_4[(orders_4)] + orders_last[("orders_5 ... orders_15")] other_tables[(Other non-sharding tablesusers, stocks, topics ...)] new_sql-->| Sharding Query | orders_4 check_table_1-.->| None sharding Query |other_tables end -posts_4-->result +orders_4-->result other_tables-.->result result[/Query results\] ``` diff --git a/docs/query.svg b/docs/query.svg index cb056db..9908005 100644 --- a/docs/query.svg +++ b/docs/query.svg @@ -1,10 +1,10 @@ -DatabaseMyConnPooldatabase/sql - ConnGormGorm QueryExistNot existNot match ShardingKeyMatch ShardingKeyGet table nameReplace TableName to get new SQLSharding QueryNone sharding Queryorders_0, orders_1 ... orders_3orders_4orders_5 ... orders_15Other non-sharding tablesusers, stocks, topics ...orders_4Check sharding rulesby table nameParser SQL to get AST +DatabaseMyConnPooldatabase/sql - ConnGormGorm QueryExistNot existNot match ShardingKeyMatch ShardingKeyGet table nameReplace TableName to get new SQLSharding QueryNone sharding Queryorders_0, orders_1 ... orders_3orders_4orders_5 ... orders_15Other non-sharding tablesusers, stocks, topics ...Check sharding rulesby table nameParser SQL to get AST - ast = sqlparser.Parse(sql)Format sql, args for get full SQL + ast = sqlparser.Parse(sql)Format sql, args for get full SQL sql = select * from orders where user_id = 100 and status = 1 - limit 10 order by id descrouter(sql, args)Sharding rulesReturn Raw SQLReturn ErrorSQL query must has sharding keyUse value in WhereValue (100) for get sharding table indexorders + (100 % 16)Sharding Table = orders_4select * from orders_4where user_id = 100 and status = 1limit 10 order by id descmatch_sharding_keyExecContextQueryContextQueryRowContextConnconnPool.QueryContext(sql, args)Gorm DBSQL Query + limit 10 order by id descrouter(sql, args)Sharding rulesReturn Raw SQLReturn ErrorSQL query must has sharding keyUse value in WhereValue (100) for get sharding table indexorders + (100 % 16)Sharding Table = orders_4select * from orders_4where user_id = 100 and status = 1limit 10 order by id descmatch_sharding_keyExecContextQueryContextQueryRowContextConnconnPool.QueryContext(sql, args)Gorm DBSQL Query select * from orders where user_id = ? and status = ? limit 10 order by id desc -args = [100, 1]Query results \ No newline at end of file +args = [100, 1]Query results \ No newline at end of file