Fork me on GitHub
#xtdb
<
2020-06-29
>
mac21:06:13

Is there a particular reason why a a query clause with all variables would not work? If I change the attribute to the value of the variable in its place it works fine.

mac21:06:01

So ['a 'b 'c] where 'b is bound to :test does not work, but ['a :test 'c] works.

refset22:06:47

Hi 🙂 This is because attributes cannot be expressed via logic variables by design. It is a consequence of keeping the query engine as low-complexity as possible whilst generating predictable and efficient query plans. Can you tell me more about why you need variable attributes? Is it something you could still potentially solve with a post-walk before submitting the query?

mac23:06:24

Well I can split the query in two and pass in the attribute as a parameter, but it feels clunky.

mac23:06:49

The reason I need it is that the attribute is a value in another document I am querying for.

refset14:06:56

ah right, yes I don't think that can be avoided. I think a two-step process is somewhat necessary when you are essentially persisting your schema into Crux as well. We have to do this for our SQL module also. Thankfully there are caches you can use as well open-db, to eliminate some of the hit. Ultimately I don't think having everything in one query could be any more efficient under the hood anyway (even with a more sophisticated planner) as you'd still be making the same number of KV seeks, which is where the real time-costs are. Perhaps you can create some kind of generalised 2-step decorator for your requirements that wraps our APIs :thinking_face:

mac18:06:27

I am not sure a general decorator could be made but I might be able to construct some convenience functions that will make it quite easy to do. Thanks for your input, it is much appreciated.

🙏 3