-- opslog:rewrites-data -- Normalise stored callsigns so lookups can use idx_qso_callsign. -- -- WorkedBefore matched rows with `upper(trim(callsign)) = ?`. Wrapping the -- column in functions makes the predicate non-sargable: SQLite cannot use the -- index and falls back to scanning. Measured on a 190 000-row logbook, the -- COUNT went from 0.3 ms (SEARCH ... USING INDEX) to 20.8 ms (SCAN), and the -- entries query — which needs every column, so not even a covering index helps -- — scans the whole table. That runs on every keystroke of a callsign, and it -- made the entry strip's history arrive too late to auto-fill the name and -- locator from the previous QSO. Small logbooks never showed it. -- -- Add, bulk insert and Update have always upper-cased and trimmed the callsign, -- so this only rewrites rows left by older versions or foreign imports, and the -- queries can then compare the column directly. -- -- SQLite compares case-sensitively, so the WHERE finds exactly the rows that -- need it. MySQL's default collation is case- and trailing-space-insensitive: -- there the UPDATE is largely a no-op and equally unnecessary, because `=` -- already matches those rows through the index. UPDATE qso SET callsign = upper(trim(callsign)) WHERE callsign <> upper(trim(callsign));