Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Store and use quick-hashed values for reverse lookups #12

@rnewman

Description

@rnewman

A common pattern is to refer to records by some unique property:

[:find ?title :where [
  [[:page/url ?] :page/title ?title]
]]
; Binding: "http://foo.com/"

That involves matching string values of :page/url to find a page, then fanning back out to title, or matching all titles and pages and narrowing by URL.

Rather than doing string matching directly, it's often more efficient to store a known hash of a value, and query with a pattern like:

["… WHERE datoms.vh = ? AND datoms.v = ?" (quick-hash val) val]

We should optionally store these in the DB:

vh INTEGER       // Can be null

With a partial index:

CREATE INDEX idx_vh ON datoms (vh, v, p) WHERE vh IS NOT NULL;

and then add flags to opt in or out on a per-attribute level. We might choose to do this automatically for string-valued unique attributes like :page/url.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions