Skip to content

Query engine (without aggregations support) for the IndexedDB web browser database with automatic query execution optimization.

License

Notifications You must be signed in to change notification settings

jurca/indexed-db-query-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IndexedDB query engine design specification

This repository houses the design of the API and proposed internal workings of a general-purpose non-aggregating query engine for the web browser-provided IndexedDB document database.

The query engine supports query analysis, optimization & preparation, user functions, and parameterized queries.

Since this is a non-aggregating query engine, it does not support operations performed on sets of records, or spanning multiple object stores.

Note that some details in this specification are deliberately left out, as this specification serves primarily as a proposal, meant to open the discussion about adding a more high-level API for using the Indexed DB API. That being said, this proposal aims to be detailed enough to make implementing it approachable and mostly straight-forward for a skilled-enough developer (with most of the code hopefully generable by a powerful-enough GPT artificial neural network).

Proposed API

This specification augments the API of IDBObjectStore with new methods for using queries, and updates some methods with query support.

These methods provide means for using queries, or prepared queries, for querying an object store for records. I suggest starting here to get a rough idea on what this repository proposes.

Proposed under-the-hood behavior

Whenever a new connection to an IndexedDB database is opened, the database will create a new QueryAnalyzer using the QueryAnalyzerFactory, ObjectStoreQueryAnalyzer using the ObjectStoreQueryAnalyzerFactory, QueryPreparer using the QueryPreparerFactory, QueryProgramExecutorFactory using the OpExecutorFactory, and QueryExecutor using the QueryExecutorFactory under the hood and keeps those instances associated with the database connection.

When a Query is to be executed or prepared for execution, and the query engine does not posses a cached PreparedQuery for the input query, it prepares the query using the following steps:

  • The query engine passes the query to the previously created QueryAnalyzer instance to produce an AnalyzedQuery for the input query.

    This step is skipped if the query engine already has a cached an AnalyzedQuery for the input query.

  • The query engine passes the AnalyzedQuery to the previously created ObjectStoreQueryAnalyzer to create an AnalyzedObjectStoreQuery for the input query and the object store for which the query is prepared.

    This step is skipped if the query engine already has a cached AnalyzedObjectStoreQuery for the input query and object store (the query engine may also reuse an AnalyzedObjectStoreQuery for the input query created for a different object store that matches all properties of the target object store).

  • The query engine then passes the AnalyzedObjectStoreQuery to the previously created QueryPreparer to create a PreparedQuery for the input query and the object store for which the query is prepared.

The prepared query is then executed using the previously created QueryExecutor instance.

About

Query engine (without aggregations support) for the IndexedDB web browser database with automatic query execution optimization.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published