insert into ebook_snapshot(ebook_id, date
, view_count, vote_count, view_increase, vote_increase)
select t1.id, curdate(), 0, 0, 0, 0
from ebook t1
where not exists(select 1
from ebook_snapshot t2
where t1.id = t2.ebook_id
and t2.date
= curdate())
[2021-08-28 21:03:31] completed in 165 ms
hswiki> insert into ebook_snapshot(ebook_id, date
, view_count, vote_count, view_increase, vote_increase)
select t1.id, curdate(), 0, 0, 0, 0
from ebook t1
where not exists(select 1
from ebook_snapshot t2
where t1.id = t2.ebook_id
and t2.date
= curdate())
[2021-08-28 21:04:18] completed in 160 ms
hswiki> update ebook_snapshot t1, ebook t2
set t1.view_count = t2.view_count,
t1.vote_count = t2.vote_count
where t1.date
= curdate()
and t1.ebook_id = t2.id
[2021-08-28 21:04:25] [23000][1048] Column ‘view_count’ cannot be null
[2021-08-28 21:04:26] [23000][1048] Column ‘view_count’ cannot be null