我想从数据库中删除与表有关系的数据,我应该使用表查询以使用 dapper 从父项和子项中删除数据。这很慢。我删除了很多数据(百万条记录)45 秒,但删除了几行在 2 分钟内执行如何以性能和快速执行此操作?
var deletequery = @"delete from DailyCodeDetail " +
@" from DailyCodeDetail dcd inner join DailyCode" +
@" dc on dcd.DailyCodeId = dc.id inner join DailyResult d on d.id=dc.DailyResultId " +
@"where d.PersonId =@Personid and dcd.DateAttendance >= @sDate and dcd.DateAttendance <= @eDate";
connection.Execute(deletequery, new { Personid = personId, sDate = sdate, eDate = edate }, commandTimeout: 1000);