You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inline INDEX in CREATE TABLE makes INSERT about 6 times slower, and DELETE and UPDATE leave the index stale #2880
Since #2614 (in 4.21.0), an inline INDEX in CREATE TABLE builds a real index. Two problems with it:
INSERT is about 6 times slower. Every inserted row runs new Function(...) once per index.
DELETE with a WHERE and UPDATE never touch the index, so it keeps deleted rows and old keys.
// 100,000 rows with INSERT INTO t SELECT ... FROM ?// CREATE TABLE t (a INT, b INT, c STRING) 52 ms// CREATE TABLE t (a INT, b INT, c STRING, INDEX ia (a), INDEX ib (b), INDEX ic (c)) 330 ms (4.20.0: 50 ms)vardb=newalasql.Database();db.exec('CREATE TABLE t (a INT, b INT, INDEX ia (a)); INSERT INTO t VALUES (1,1),(2,2),(3,3)');db.exec('DELETE FROM t WHERE a = 2');db.exec('UPDATE t SET a = 10 WHERE a = 3');db.tables.t.indices;// still {"1": ..., "2": ..., "3": ...}: no 10, and 2 is still there
Results are still right only because nothing reads these indexes yet. SHOW INDEX reports the wrong sizes, and the memory of deleted rows is held. Every MySQL dump with inline INDEX pays the insert cost.
The fix: compile the index function once and keep it on the index (the same for CREATE INDEX), and keep the index in step on DELETE and UPDATE (src/statements/delete.js, src/statements/update.js), or do not fill an index that nothing reads.
Activity
mateuscmtropical commentedon Nov 11, 2026
Hi, I'd like to work on this one.
mateuscmtropical commentedon Nov 11, 2026
Hi, I've opened a PR for this: #2987