-
Notifications
You must be signed in to change notification settings - Fork 212
Is there any practice of table sharding? #563
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
Comments
default List<Object> select(String table, SelectDSLCompleter completer) {
return MyBatis3Utils.selectList(this::selectMany, selectList, tableItem.withAlias(table), completer);
} this is one example I want to do, but it may be difficult to insert with sharding |
The It's not so easy to use right now because there's no way to change that function after the table is created, and MyBatis generator doesn't generate code for it. I'll think about a way to make it easier to use. |
Thanks for your reply!
This table display some point of sharding table. It may provide some help. |
I'm not sure I understand your table. Does "muti table" mean "mutate table" (change the table name)? I'm thinking of making a change that will make it easier to do something like that. Take a look at this test in my branch: https://github.com/jeffgbutler/mybatis-dynamic-sql/blob/bcf7ed8ded025dc799c5c608bf19db74c44f3b9e/src/test/java/examples/sharding/ShardingTest.java Especially look at these lines line that will select an instance of the table with a different name based on a sharding algorithm: https://github.com/jeffgbutler/mybatis-dynamic-sql/blob/bcf7ed8ded025dc799c5c608bf19db74c44f3b9e/src/test/java/examples/sharding/ShardingTest.java#L157-L167 Note that this does not change the table object - it creates a new instance with a different name. I'm very committed to immutable objects in the library. Would a change like this meet your needs? |
Very sorry for my late reply. This change is very suit for my needs. Only one further thing is how to |
@GOODDAYDAY this support is now merged into the library. For MyBatis batch support, it is important to make sure that the inserts to the various tables are kept together in the list of inserts. You must do this on your own. |
OK, Thanks a lot @jeffgbutler |
Hi all!
I notice that the code generated of table item is changeless.
So if I want run a SQL with table like table_1,table_2... is complex that I need to write one function with
table item
param input or something else.I'd want to know if anyone has some good practice of table sharding by id or time or anything else.
Regards,
Goody
The text was updated successfully, but these errors were encountered: