Replies: 16 comments 32 replies
-
0.0说来惭愧本来联系叶老板打算做freesql的分片支持结果工作上很忙时间一直抽不出来,不过这边提一点意见
|
Beta Was this translation helpful? Give feedback.
-
目前框架提供的自动分表其实就我个人经验而言并不是一个功能,严格意义上来说应该是两个功能
以上两点其实就是自动分表的本质,并且如果框架提供了以上两种功能应该说就可以实现所有的分片路由规则,至于是否自动分表其实就是动态分片在程序里面的应用而已,自动并不是真正意义的自动,而是框架提供了动态添加路由,刚好根据时间又可以解析出分片所需的后缀仅此而已 |
Beta Was this translation helpful? Give feedback.
-
[Table(Name = "as_table_log_{yyyyMM}", AsTable = "createtime=2022-1-1(1 month)")]
class AsTableLog
{
public Guid id { get; set; }
public string msg { get; set; }
public DateTime createtime { get; set; }
} 我想再集成一个功能,id 是 FreeSql 创建,并且它的值包含 createtime,那么 根据 id 查询时,可以直接解析出 createtime 值,同时也可以直接定位到对应的分表 |
Beta Was this translation helpful? Give feedback.
-
能否提供db-first场景下的按时间日期分表 |
Beta Was this translation helpful? Give feedback.
-
当采用子查询的写法时,子表的时间过滤有问题。主表和子表都是按照月份分表,从2022-1-1开始,主表成功按照时间筛选只查了一张表,子表只查了5月那张表,但是UNION ALL了5次 查询的表达式
生成的sql
|
Beta Was this translation helpful? Give feedback.
-
自定义分表暂时可以这样: 第一步:class DateTimeAsTableImpl : IAsTable 把这个类复制出去,改成你想要的 第二步:fsql Build 之后执行下面代码 var tb = fsql.CodeFirst.GetTableByEntity(typeof(分表的实体类));
var atm = Regex.Match(tb.AsTable, @"([\w_\d]+)\s*=\s*(\d\d\d\d)\s*\-\s*(\d\d?)\s*\-\s*(\d\d?)\s*\((\d+)\s*(year|month|day|hour)\)", RegexOptions.IgnoreCase);
var astableImpl = new DateTimeAsTableImpl(Name, DateTime.Parse($"{atm.Groups[2].Value}-{atm.Groups[3].Value}-{atm.Groups[4].Value}"), dt =>
{
switch (atm6)
{
case "year": return dt.AddYears(atm5);
case "month": return dt.AddMonths(atm5);
case "day": return dt.AddDays(atm5);
case "hour": return dt.AddHours(atm5);
}
throw new NotImplementedException();
});
tb.GetType().GetProperty("AsTableImpl").SetValue(astableImpl, new object[0]); |
Beta Was this translation helpful? Give feedback.
-
在不开启自动迁移的情况下,有没有办法手工创建分表,oracle当数据量大的时候自动迁移有时候会卡住。 |
Beta Was this translation helpful? Give feedback.
-
叶老板 现在自动分表不支持分页查询吗 |
Beta Was this translation helpful? Give feedback.
-
开启自动迁移就可以
…---原始邮件---
发件人: "Alex ***@***.***>
发送时间: 2022年11月20日(周日) 上午8:48
收件人: ***@***.***>;
抄送: ***@***.******@***.***>;
主题: Re: [dotnetcore/FreeSql] v3.2 新功能【自动分表】讨论与反馈 (Discussion #1066)
现阶段是每次都会执行自动迁移脚本吧? 有人生产用了吗
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
我目前的情况 问,这三个程序。怎么用freesql为最佳实践 |
Beta Was this translation helpful? Give feedback.
-
采用按周自动分表,数据库是Mysql,数据库配置已优化,现在是定时(每隔2秒)拆入几条数据,每张表数据量在几十万条,正常插入几条数据耗时 不到100ms,一天过程中可能出现十几次次插入数据 耗时几秒或者十几秒,这种情况要从哪些方面着手? |
Beta Was this translation helpful? Give feedback.
-
您好,
SQL语句里面就是insert.....,看不出什么异常,另外之前看了mysql的bin日志 只是记录现场,分析不出是什么原因。
…------------------ 原始邮件 ------------------
发件人: "dotnetcore/FreeSql" ***@***.***>;
发送时间: 2024年1月5日(星期五) 中午12:12
***@***.***>;
***@***.******@***.***>;
主题: Re: [dotnetcore/FreeSql] v3.2 新功能【自动分表】讨论与反馈 (Discussion #1066)
把耗时的前后 SQL 监视下来分析
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
-
使用分页+WithTempQuery+OrderBy出现问题
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
时间戳可以分表吗 毫秒级的时间戳 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
【自动分表】不同于之前的 CURD.AsTable 方法,目前第一期完成按【时间】自动分表(不支持分库)。
欢迎积极参与测试、反馈,请优先使用源代码进行测试,方便反馈定位问题,谢谢。
1、定义特性
第一个表12个月,后面的表按1个月:
第一个表非时间命名:
每个月1日10点分表:
未设置时间条件时,只命中最新的 3个分表:
2、创建分表
当开启自动迁移时,分表会自动创建。
3、插入数据时,根据对应属性值,自动对应分表
打印 sql:
4、删除数据
根据 id 删除一行数据,可能要每个分表都行进删除操作,FreeSql 可以根据 sql where 缩小执行范围
打印 sql:
分表太多了,当
删除/更新/查询
未设置时间条件时,只命中最新的 3个分表:5 、更新数据
可根据实体对象对应分表,或者逆向解析 sql where 文本,缩小执行范围
用例1,更新单个实体
打印 sql:
用例2,批量更新实体
打印 sql:
用例3,直接更新字段(不传递实体)
打印 sql:
用例4,直接更新字段,传入 where 时间缩小执行范围(不传递实体)
打印 sql:
6、查询数据,根据 sql where 缩小执行范围
分表 join 普通表:
普通表 join 分表:
分表 join 分表:
嵌套查询:
Beta Was this translation helpful? Give feedback.
All reactions