Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce in predicate to check against a set of values #213

Open
maydanw opened this issue Jun 8, 2021 · 2 comments
Open

Introduce in predicate to check against a set of values #213

maydanw opened this issue Jun 8, 2021 · 2 comments

Comments

@maydanw
Copy link

maydanw commented Jun 8, 2021

Problem to Solve

Concrete example:
Given a list of 1000s of document entities ids retrieved from a search in ES we want to check if a user has access to each of them and filter them.
The current options are either:

  1. Running 1000s of independent queries
  2. Build a query with 1000s of independent OR statements

Both are inefficient

Current Workaround

  1. Running 1000s of independent queries
  2. Build a query with 1000s of independent OR statements

Proposed Solution

Add "in" (or "isIn") construct to the syntax
For example (in python):

query = "match $d isa document, has objID in ["123", "1122", "333AAA", "6A5B"]; ..."

Additional Information

Beyond improving the ease of usage, I (@maydanw) believe this can be optimized due to:

  • Server caching - from my understanding lots of the reasoner caching is only inside the tx,
  • Same server snapshot
  • It can have better server CPUs utilization
  • Less network communication
  • Validating the predicate value in the list can be hashed instead of searched for each.
@alexjpwalker alexjpwalker changed the title Adding "in" to the TypeDB syntax Adding "in" (with list of arguments) to the TypeDB syntax Jun 8, 2021
@alexjpwalker alexjpwalker changed the title Adding "in" (with list of arguments) to the TypeDB syntax Adding "in" (with a list of arguments) to the TypeDB syntax Jun 8, 2021
@flyingsilverfin flyingsilverfin changed the title Adding "in" (with a list of arguments) to the TypeDB syntax Introduce in predicate to check against a set of values Jan 10, 2023
@flyingsilverfin
Copy link
Member

flyingsilverfin commented Jan 10, 2023

This might naturally be incldued in the future when we include vectors or sets of values natively in TypeDB?

related:
typedb/typedb#6327

@flyingsilverfin
Copy link
Member

flyingsilverfin commented Mar 16, 2023

Related to typedb/typedb#5527

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

No branches or pull requests

2 participants