mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Add sql condition for speedup in write_introduced
This commit is contained in:
parent
3cecc7157b
commit
11cd1d9a26
1 changed files with 10 additions and 4 deletions
|
@ -500,8 +500,11 @@ impl SqlWriter<'_> {
|
||||||
let cutoff = self.cutoff_in_secs_from_days(days)? * 1_000;
|
let cutoff = self.cutoff_in_secs_from_days(days)? * 1_000;
|
||||||
write!(
|
write!(
|
||||||
self.sql,
|
self.sql,
|
||||||
|
concat!(
|
||||||
"(select min(id) > {} from revlog where cid = c.id)",
|
"(select min(id) > {} from revlog where cid = c.id)",
|
||||||
cutoff
|
"and c.id in (select cid from revlog where id > {})"
|
||||||
|
),
|
||||||
|
cutoff, cutoff,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -671,8 +674,11 @@ mod test {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s(ctx, "introduced:3").0,
|
s(ctx, "introduced:3").0,
|
||||||
format!(
|
format!(
|
||||||
"((select min(id) > {} from revlog where cid = c.id))",
|
concat!(
|
||||||
(timing.next_day_at.0 - (86_400 * 3)) * 1_000
|
"((select min(id) > {cutoff} from revlog where cid = c.id)",
|
||||||
|
"and c.id in (select cid from revlog where id > {cutoff}))"
|
||||||
|
),
|
||||||
|
cutoff = (timing.next_day_at.0 - (86_400 * 3)) * 1_000,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert_eq!(s(ctx, "introduced:0").0, s(ctx, "introduced:1").0,);
|
assert_eq!(s(ctx, "introduced:0").0, s(ctx, "introduced:1").0,);
|
||||||
|
|
Loading…
Reference in a new issue