Skip to content

Performance issues at AlaSQL database queries - response time of several minutes #1027

Closed

Description

@airpressurerecords

Hello,

I am using AlaSQL in a Node.js application.

What I do in build time:

  1. load JSON files into JSON objects.
  2. create database with 3 tables based on that files.
  3. fill the table with the JSON objects
    The total amount of data sets is about 2500.

What I do in runtime:
AlaSQL queries, which need to be synchronous and have 2 joins, so all 3 tables are included.

Issue:
When I query the data I get a response time of several minutes. Does anyone know how to fix that or how to do it better?

What I tried:

  • adding primary key (index) to data sets
  • reducing data
    Unfortunately did not work

Thank you in advance.

Activity

  1. changed the title [-]Performance issues at database queries[/-] [+]Performance issues at database queries - response time of several minutes[/+] on Jul 4, 2018
  2. changed the title [-]Performance issues at database queries - response time of several minutes[/-] [+]Performance issues at AlaSQL database queries - response time of several minutes[/+] on Jul 4, 2018
  3. mathiasrw commented on Jul 5, 2018

    @mathiasrw
    Member

    There is something about the index not working when loading data directly. hmmm.

    Can you try to load data via SQL and see if it works better?

    Can you share the SQL to see what the structure is like?

  4. freyley commented on Oct 27, 2019

    @freyley

    I'm exploring performance with AlaSQL and not seeing much evidence that indexes do anything. I created a database with 256k records and attempted to query for a sorted subset, only to find it takes 500-1300ms to do so, and indexes do not seem to have any affect on this. I created a codepen - https://codepen.io/freyley/pen/GRREdom

  5. mathiasrw commented on Jan 2, 2020

    @mathiasrw
    Member

    Hmm. Iteresting to see if the speed tricks is disabled for sorted subsets (it should not)

    If you could make an exaple of a query that ou find strangly slow it would really be awesome.

  6. freyley commented on Jan 2, 2020

    @freyley

    @mathiasrw take a look at the codepen above, it was, last October, in the console, outputting its times to do pretty simple queries.

  7. tran4o commented on May 4, 2020

    @tran4o

    I have the same issue and have very simple example to show how indexes are really not useful for any real nested query with simple joins :

    alasql("CREATE TABLE test (id number, child number)");
    for (var i=0;i<100000;i++)
    alasql("INSERT INTO test VALUES ("+i+","+Math.floor(Math.random()*250)+")");
    alasql("CREATE INDEX test_1 ON test(id)");
    alasql("CREATE INDEX test_2 ON test(child)");

    //---------------
    alasql("SELECT a.id,b.id FROM test AS a JOIN test AS b ON (a.id = b.id) WHERE a.id = 10")
    // 3+ seconds, neither 'Joined tables are pre-indexed' nor 'WHERE expressions are pre-filtered for joins'

    // 3+ seconds, same result
    alasql("SELECT a.id,b.id FROM test AS a JOIN test AS b ON (a.id = b.id)")

  8. tran4o commented on May 4, 2020

    @tran4o

    I found the problem in the implementation in this case.
    Following sql does works as expected also without indexes in some milliseconds :

    alasql("SELECT a.id,b.id FROM test AS a JOIN test AS b ON a.id = b.id")

    does not work :

    alasql("SELECT a.id,b.id FROM test AS a JOIN test AS b ON (a.id = b.id)")

    the problem seems to be in src/421join.js:312
    the optimizer expects direct join condition, without dummy UniOp node

    https://imgur.com/a/IzldRHU

  9. added a commit that references this issue on Nov 20, 2025
    aa3ea87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions