Skip to content
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

Closed
rnewman opened this issue Jul 15, 2016 · 2 comments
Closed

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

rnewman opened this issue Jul 15, 2016 · 2 comments

Comments

@rnewman
Copy link
Collaborator

rnewman commented Jul 15, 2016

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.

@ncalexan
Copy link
Member

This is an interesting proposal. I like the last part: "automatic[ally] for string-valued unique attributes".

@rnewman
Copy link
Collaborator Author

rnewman commented Jul 15, 2016 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants