Skip to content

Direct schema update via API #296

@eugenefomenko

Description

@eugenefomenko

First of all, thank you for such a powerful tool!

I am excited to use sqlynx to provide autocomplete features within our browser-based code editor.
However, I've encountered some limitations, particularly when it comes to efficiently handling databases with a large number of tables. Currently, the tool requires an external script containing SQL instructions (e.g., CREATE TABLE) for accurate hints.

The issue arises in terms of performance, especially with databases containing thousands of tables. Parsing this script for schema information impacts performance by freezing the page for several seconds.

It would be nice to have additional API methods that allow direct updates to the completion index with new identifiers. Ideally, these changes could look like:

interface Schema {
    tables: {
        tableName: string;
        columns: string[];
    }[];
}

getSchema(): Schema
addTable(tableName: string, columns: string[]): Schema
removeTable(tableName: string): Schema

With packing data into corresponding flatbuffers structure.

Here's a bit of context regarding our usage scenarios:

  • During document initialization, we get analyzedScript.tableReferences and analyzedScript.columnReferences, searching for matches within our internal storage and updating the schema.
  • Similarly, while users type text, we continuously check for new table and column identifiers and update the schema.
  • When executing a DROP TABLE statement, we remove the table from the schema.

Implementing these changes would significantly enhance performance, especially in scenarios with massive database schemas.

Thank you for considering these changes!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions