Skip to content

Compile time doubles with every EXISTS in a query #3133

Backlog

Description

@mathiasrw
alasql('CREATE TABLE t (a INT); INSERT INTO t VALUES (1)');
alasql('CREATE TABLE w (b INT); INSERT INTO w VALUES (1)');
for (const n of [10, 12, 14, 16]) {
  const sql = 'SELECT a FROM t WHERE ' + Array(n).fill('EXISTS (SELECT 1 FROM w)').join(' AND ');
  const start = Date.now();
  alasql(sql);
  console.log(n, Date.now() - start, 'ms');
}

It prints about 25, 50, 220 and 800 ms. Every EXISTS doubles the time, as a SELECT is compiled 2^n times for n EXISTS (4,096 times for 12).

The time should grow linearly, with one compile per SELECT.

Fixed by #2666.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions