How many rules does the TypeDB support?

Hi, there

I’m using the TypeDB 2.11.1 and noticing that it will take ~1 second for 1 rule to write into the schema. Based on my situation and also the fact that the rule doesn’t support disjunction, eventually, it will have thousands of rules.

My questions are:

  1. How many rules does TypeDB support? Is there any maximum number limit?
  2. Any way to speed up the rule writing process? What kind of conditions relate to the speed?
  3. The nature of my model is that the number of rules are much much bigger than the number of entities, because the model is based on heavy deductive logic. For exmaple, it will have 2000 rules based on 8 entities. Is TypeDB the right choice to this kind of certain job?

Thanks for any help~

Hi Zack!

Just on Tuesday we released TypeDB 2.14.1, which improved the speed of rule validation. You can download it now from our download centre and try it out.

To answer your questions directly:

  1. There’s no theoretical limit to how many rules TypeDB can support.
  2. Providing additional constraints such as typing information to your rules speeds up validation time dramatically. For example, use $p isa person, has name "Zack" instead of $p has name "Zack". By keeping the scope of possible types $p could be as tight as possible, the rule validator only has to validate the necessary types.
  3. TypeDB is definitely an excellent choice for any job that involves large amounts of deductive logic.

Just a helpful hint: adding new rules will only have to validate the new rules, but adding new types means all of the rules have to be re-validated according to these new types. The order of operations here matters greatly!

Let us know if you have any further questions or need assistance in getting up and running.

I tried 2.14.1, it’s 10 times faster than 2.11.1. Thanks for the info! Any suggestions on how to deal with the non-disjunction of rule? I’m using groups of rules to mimic the behavior now, which sounds not smart at all.

Hi Zack! Just a heads up Rules can now contain disjunctions :slight_smile:

Wow! Awasome! I checked the official doc that’s not updated yet. Any place to learn and play with the disjunctions of rules?

Good point, I just updated a line on the docs to note we can include disjunctions. Here’s an example:

when {
  $x isa person, has age $a;
  { $a < 18; } or { $a > 65; };
} then {
  $x has discount-pricing true;

Many thanks! That’s what exactly I’m waiting for. :+1:

disjunction error in 2.14.1. It seems doesn’t work for me. Any clue why?

You may also need to update to the latest version of TypeDB Studio - have you downloaded Studio 2.14.1?

Yes, it’s 2.14.1. I double checked, it’s still the same error.

PS: I would recommend avoiding | to improve performance and use or instead

$x1 like “(a|b)” works for me, but {$x1 a;} or {$x1 b;}; doesn’t work with errors. That’s why I’m using like to mimic the disjunction.

Interesting, what kind of errors? that is unexpected.

Error> [TQL30] TypeQL Error: Rule ‘is-AAA’ ‘when’ contains a disjunction.

This error seems mean that the rule can NOT support disjunction.

Ah, how interesting. It appears the latest TypeDB client-java is using the previous version of the language parser that does not allow rules to contain disjunctions, while the server is operating over disjunctions in rules correctly. We’ll have to think about how to address that gap in our testing.

Thanks for the heads up, we’ll release the fixed versions tomorrow!

Wonderful! Can’t wait for the disjunction update.

@zack Try out 2.14.2, it should be working now :slight_smile:

Thanks, Joshua! Some feedback: Tried TypeDB 2.14.2 with TypeDB studio 2.14.1, the error is still showed up when importing to schema, however after clicking the check mark, it says being successfully commited. Then, when trying the match query, there is no ruled relations showed up, which are supposed to have. Do I need to use studio 2.14.2 to pair the new TypeDB? But I don’t have the release.

Hi Zack,

My apologies, Studio release is lagging by a few days while we work on some necessary fixes. I’ll drop you a message here once it’s released.

For now, your workaround sounds as though it should be working. Have you turned infererence on before running the query?

If it is somehow the case that your rules are being removed from your schema before committing, I’d advise committing your schema through another means such as Console (Release TypeDB Console 2.14.2 · vaticle/typedb-console · GitHub) and then using Studio normally from then on. Let us know if you encounter any issues in doing so.

Hi @zack, Studio 2.14.2 has just been released! Here’s a link to the release page: Release TypeDB Studio 2.14.2 · vaticle/typedb-studio · GitHub

Let me know if you have any trouble getting this working.