Skip to content

Releases: blinkdb-js/blinkdb

v0.14.0 & v0.0.3@react

19 Oct 19:46
Compare
Choose a tag to compare

BREAKING CHANGES

removeMany now returns the number of items deleted, not a boolean that states whether all items have been deleted.

If you still need to check whether all entities you provided have been deleted, you can rewrite your removeMany calls.

Before:

const allEntitiesDeleted = await removeMany(table, [{ id: "0" }, { id: "1" }]);

After:

const items = [{ id: "0" }, { id: "1" }];
const numDeleted = await removeMany(table, items);
const allEntitiesDeleted = numDeleted === items.length;

What's Changed

  • missing keys in removeWhere is no-op by @retorquere in #30
  • Changed removeMany to return number of items deleted

New Contributors

Full Changelog: v0.13.3...v0.14.0

v0.0.2@react

18 Sep 16:41
Compare
Choose a tag to compare

What's changed

  • Fixed #24, where changing the query parameters of useMany exported by the blinkdb@react package did not update watch

v0.13.3

08 Jul 12:56
Compare
Choose a tag to compare

What's changed

⚑ v0.13.3 is primarily a performance release. While blinkDB is a read optimized database, this time we heavily optimized insertions.

  • Fixed issue with failing benchmarks. Some benchmarks were throwing errors that were not reported back to the runner, and the benchmarking framework was not running prerequisite hooks on warmup, leading to false reports. These issues have been fixed, and benchmarks like insertMany now report back correctly.
  • insertMany performance optimizations. Thanks to @Valerionn, insertMany is now up to +45% faster by removing the need to allocate event objects if no events are registered on insert.
  • general performance optimizations. All blinkDB packages now compile directly to ES6, and public functions return Promises directly instead of using the async function modifier. Because this removes the need for TS to include wrapper functions for async code, which is a constant overhead, this resulted in an increase of performance in all public functions in the blinkdb package ranging from +5% (O(n log n) operations like insertMany & upsertMany) to +80% (O(1) operations like count).

As an example, on the insert-many benchmark, BlinkDB went from this:

blinkdb/insert-many.ts --- lokijs is 1.51x faster than blinkdb
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚   name    β”‚      ops/sec      β”‚ Average Time (ns)  β”‚  Margin   β”‚ Samples β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ 'lokijs'  β”‚ 256.3883418534088 β”‚ 3900333.3488999065 β”‚ 'Β±8.15%'  β”‚   129   β”‚
β”‚    1    β”‚ 'blinkdb' β”‚ 169.8885317147108 β”‚ 5886212.505969931  β”‚ 'Β±17.15%' β”‚   85    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

to this:

blinkdb/insert-many.ts --- blinkdb is 1.04x faster than lokijs
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚   name    β”‚      ops/sec      β”‚ Average Time (ns)  β”‚  Margin   β”‚ Samples β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ 'blinkdb' β”‚ 310.7162169122418 β”‚ 3218370.801297566  β”‚ 'Β±10.35%' β”‚   156   β”‚
β”‚    1    β”‚ 'lokijs'  β”‚ 298.5117428378887 β”‚ 3349951.9666905203 β”‚ 'Β±9.36%'  β”‚   150   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Full Changelog: v0.13.2...v0.13.3

v0.13.2

05 Jul 23:22
Compare
Choose a tag to compare

What's changed

  • The blinkdb & @blinkdb/react package now target es6 instead of es5 to prevent transpilation of classes.

Full Changelog: v0.13.1...v0.13.2

v0.13.1

03 Jul 13:50
Compare
Choose a tag to compare

What's changed

  • Fixed issue with incorrect type causing type inference problems: #20

v0.13.0

27 Jun 19:23
Compare
Choose a tag to compare

What's changed

Full Changelog: v0.12.2...v0.13.0

v0.12.2

13 Jun 16:47
Compare
Choose a tag to compare

What's Changed

  • fix: broken filters link on changes.mdx by @ThaisRobba in #17
  • fix: export query types #15

New Contributors

Full Changelog: v0.12.0...v0.12.2

v0.12.0

01 May 22:01
a7569d8
Compare
Choose a tag to compare

BREAKING CHANGES

  • watch() now returns the method to stop watching changes directly instead of an object with the stop method.

Before:

const { stop } = await watch(...);

After:

const stop = await watch(...);
  • All exceptions have been rewritten to custom classes that extend Error, so checking for problems is easier.

Before:

import { insert } from "blinkdb";

try {
  await insert(userTable, ...);
} catch(e) {
  // Check if the error is due to the primary key already existing.
  if(e.message.match(/Primary key .* already in use./g)) {
    console.log("Key in use :(");
  }
}

After:

import { insert, PrimaryKeyAlreadyInUseError } from "blinkdb";

try {
  await insert(userTable, ...);
} catch(e) {
  // Check if the error is due to the primary key already existing.
  if(e instanceof PrimaryKeyAlreadyInUseError) {
    console.log("Key in use :(");
  }
}

What's changed

  • update() & updateMany() now return the primary keys of the items updated.
  • New upsert(...) & upsertMany(...) that update an entity, or insert it if it's not yet present within the table.
  • first() & one() now also accept an id directly as the second parameter, which is a faster method than using a query { where: { id: "<id>" } }.
  • watch() has been rewritten with increased performance and correctness.
    • fixed issue with watch() returning incorrect data if a limit is specified.
    • used better algorithm for inserting newer entities into the sorted list instead of inserting & sorting afterwards.

Full Changelog: https://github.com/blinkdb-js/blinkdb/commits/v0.12.0

v0.11.0

26 Apr 17:55
Compare
Choose a tag to compare

v0.11 of BlinkDB arrives with massive improvements to the query engine, specifically for limiting & sorting results.

Before

blinkdb\limit-from.ts --- lokijs is 5.00x faster than blinkdb
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚   name    β”‚      ops/sec      β”‚ Average Time (ns) β”‚  Margin  β”‚ Samples β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ 'lokijs'  β”‚ 16588.13217232204 β”‚ 60284.06270288466 β”‚ 'Β±1.01%' β”‚  8295   β”‚
β”‚    1    β”‚ 'blinkdb' β”‚ 3319.452529365677 β”‚ 301254.4963825986 β”‚ 'Β±3.59%' β”‚  1668   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
blinkdb\sort-id-asc.ts --- lokijs is 1.22x faster than blinkdb
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚   name    β”‚      ops/sec       β”‚ Average Time (ns) β”‚  Margin  β”‚ Samples β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ 'lokijs'  β”‚ 1882.3348864078623 β”‚ 531255.0955841558 β”‚ 'Β±2.41%' β”‚   942   β”‚
β”‚    1    β”‚ 'blinkdb' β”‚ 1541.504252178804  β”‚ 648716.9909434716 β”‚ 'Β±7.26%' β”‚   771   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

After

blinkdb\limit-from.ts --- blinkdb is 3.10x faster than lokijs
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚   name    β”‚      ops/sec       β”‚ Average Time (ns)  β”‚  Margin  β”‚ Samples β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ 'blinkdb' β”‚ 50585.49415326716  β”‚ 19768.513024111937 β”‚ 'Β±8.57%' β”‚  25293  β”‚
β”‚    1    β”‚ 'lokijs'  β”‚ 16296.938372072096 β”‚  61361.218725211   β”‚ 'Β±2.90%' β”‚  8156   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
blinkdb\sort-id-asc.ts --- blinkdb is 2.61x faster than lokijs
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚   name    β”‚      ops/sec       β”‚ Average Time (ns)  β”‚  Margin  β”‚ Samples β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ 'blinkdb' β”‚ 4057.786560018582  β”‚ 246439.77331213318 β”‚ 'Β±7.94%' β”‚  2029   β”‚
β”‚    1    β”‚ 'lokijs'  β”‚ 1557.6211865036469 β”‚ 642004.6213191763  β”‚ 'Β±2.88%' β”‚   779   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Implementation details

BlinkDB achieves this massive speedup by exploiting certain edge cases in queries:

  • In previous implementations, limiting results with from was performed after all items were retrieved from the underlying btree. from is now respected directly in the btree in all cases where where the query engine uses the primary column for item retrieval.
  • Sorting items can be entirely skipped if the query engine retrieved items from the primary column, since the Btree already returns the items sorted.

v0.10.0

05 Mar 23:10
Compare
Choose a tag to compare

What's Changed

  • BlinkDB introduces middleware! Hook right into BlinkDB methods with the new use() method, which lets you modify parameters & return values of various functions of BlinkDB. See the docs for more details.
use(userTable, async (ctx) => {
  // Execute code before calling the implementation
  console.log(ctx.action); // Log the method called
  console.log(ctx.params); // Log parameters given to the method

  // Call the native implementation
  const result = await ctx.next(...ctx.params);

  // Execute code after the implementation
  console.log("Everything worked!");

  // Don't forget to return the result ;)
  return result;
})