dynamic = rather than glob

This commit is contained in:
polv committed 2026-03-06 23:17:14 +07:00
1 parent 7df0ad6066
commit 729f6635fc
1 file changed
+13 -11
+13 -11
View File
@@ -54,8 +54,11 @@ impl YomitanDatabase {
}
new_t.push_str(&normalize_term(&new_seg));
let q_term_norm = new_t;
let eq1 = if q_term_norm.len() > 0 { "GLOB" } else { "=" };
let eq2 = if q_reading.len() > 0 { "GLOB" } else { "=" };
let conn = self.db.conn.lock().unwrap();
conn.execute_batch(
@@ -74,10 +77,9 @@ impl YomitanDatabase {
DELETE FROM yomitan_lookup_keys;
",
)?;
// let _timer = Timer::new(format!("search_yomitan: {} {}", q_term, q_reading));
conn.execute(
&format!(
// let _timer = Timer::new(format!("search_yomitan: {} {}", q_term, q_reading));
let sql_string = format!(
"
INSERT INTO yomitan_lookup_keys
SELECT
@@ -93,16 +95,16 @@ impl YomitanDatabase {
FROM yomitan.terms t
JOIN yomitan.view_terms_term_rank tr ON tr.term = t.term AND tr.reading = t.reading
JOIN yomitan.dictionaries d ON d.id = t.dict_id
WHERE t.term_norm GLOB ?1 {} t.reading GLOB ?2
WHERE t.term_norm {eq1} ?1 {and_or} t.reading {eq2} ?2
ORDER BY tr.max_score DESC, d.sort_order DESC
LIMIT ?3 OFFSET ?4
",
and_or
),
params![q_term_norm, q_reading, limit, offset],
)?;
// let _timer = Timer::new(format!("search_yomitan: {} {}", q_term, q_reading));
"
);
// println!("{}", sql_string);
// still the most time bottleneck step, several seconds
conn.execute(&sql_string, params![q_term_norm, q_reading, limit, offset])?;
// let _timer = Timer::new(format!("search_yomitan: {} {}", q_term, q_reading));
let mut stmt = conn.prepare(
"
SELECT