Don't target all_datoms when an unbound attribute is known to be non-textual #67

Open
opened 2020-08-06 16:54:21 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:54:21 +00:00 (Migrated from github.com)

Consider this query:

(datomish.query/find->sql-string
  (datomish.query.context/->Context (datomish.query.source/datoms-source nil) nil nil)
  (datomish.query/parse
   '[:find ?e ?a ?v
     :in $
     :where [?e ?a ?v]
            [(> ?v 1000)]])
  {})

Currently this produces SQL:

["SELECT DISTINCT all_datoms11581.e AS e, all_datoms11581.a AS a, all_datoms11581.v AS v FROM all_datoms all_datoms11581 WHERE (all_datoms11581.v > ?) " 1000]

Two situations should change this:

  • There are no fulltext attributes in the schema.
  • A value is constrained to be non-textual (e.g., a clause like [(< ?v 5)] is present).

In these situations, rather than targeting all_datoms (which is a view that includes the join between fulltext_datoms and fulltext_values), we should target only datoms.

Consider this query: ``` (datomish.query/find->sql-string (datomish.query.context/->Context (datomish.query.source/datoms-source nil) nil nil) (datomish.query/parse '[:find ?e ?a ?v :in $ :where [?e ?a ?v] [(> ?v 1000)]]) {}) ``` Currently this produces SQL: ``` ["SELECT DISTINCT all_datoms11581.e AS e, all_datoms11581.a AS a, all_datoms11581.v AS v FROM all_datoms all_datoms11581 WHERE (all_datoms11581.v > ?) " 1000] ``` Two situations should change this: - There are no fulltext attributes in the schema. - A value is constrained to be non-textual (_e.g._, a clause like `[(< ?v 5)]` is present). In these situations, rather than targeting `all_datoms` (which is a view that includes the join between `fulltext_datoms` and `fulltext_values`), we should target only `datoms`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#67
No description provided.