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
Indexes are not used for WHERE on the first table, only for JOIN ... ON #2746
CREATE INDEX and PRIMARY KEY do not make a WHERE on the indexed column faster: the table is scanned in full either way.
alasql('CREATE TABLE ix (id INT PRIMARY KEY, email STRING, score INT)');alasql('CREATE INDEX ix_email ON ix (email)');alasql('CREATE TABLE nx (id INT, email STRING, score INT)');// 200,000 rows into eachalasql("SELECT * FROM ix WHERE email = '[email protected]'");// 10 to 24 msalasql("SELECT * FROM nx WHERE email = '[email protected]'");// 10 to 15 msalasql('SELECT * FROM ix WHERE id = 9999');// 10 to 17 ms
Meanwhile the indexes make writes slower: a bulk INSERT ... SELECT of 25,000 rows takes 75 ms into a table with a primary key and two indexes, against 5 ms without them (benchmark dimension indexes, #2742).
Cause: src/38query.js uses table.indices only for a joined table (k > 0 && source.optimization == 'ix', built from the ON condition). The first table in FROM never looks at its indexes, and the WHERE is not used to pick one. #1312 asks how to add indexes to speed up queries; today they only help the right side of a JOIN ... ON.
Activity