Hi everyone, we're using SpiceDB with this schema:...
# spicedb
l
Hi everyone, we're using SpiceDB with this schema:
Copy code
definition user {}
definition any_user {}
definition subscription {
    relation subscriber: user
}
definition subscription_plan {
    relation subscriber: subscription#subscriber
}

definition channel {
    relation viewer: subscription_plan#subscriber with devices_under_limit | any_user
    permission view = viewer
}

caveat devices_under_limit(current_device_count uint, current_k_plus_device_count uint, max_device_count uint, max_k_plus_device_count uint) {
    current_device_count <= max_device_count && current_k_plus_device_count <= max_k_plus_device_count
}
We're facing problem with this check:
Copy code
zed permission check channel:02efed81-3e71-4328-89dc-667c33fa0e9f view user:779ddaf2-f76c-4414-9f23-9430418849ff --endpoint 127.0.0.1:50051 --token preshared-key --insecure --consistency-full --explain --max-message-size 7135172 --caveat-context '{"current_device_count":1,"current_k_plus_device_count":0,"max_device_count":10,"max_k_plus_device_count":10}'
We notice that we it resolves sub problem between
subscription_plan
and
user
, there is one plan that has about 110k
subscribers
, (in total, ,there are 51
plans
, and 190k
subscribers
). Which makes the query slow and then we ended up in memory spike, (around 3GB in just 5 minutes). Also, the number of go-routines is up to 12.000. Any idea to resolve this problem? Do we have to flat out the schema? https://cdn.discordapp.com/attachments/844600078948630559/1491350556038660166/Screenshot_2026-04-08_at_15.12.22.png?ex=69d75ff0&is=69d60e70&hm=4f7f292a6de5963f351b6562a4579760fd7914389aeb1178750b83fbfa32c156& https://cdn.discordapp.com/attachments/844600078948630559/1491350556554563734/Screenshot_2026-04-08_at_15.12.46.png?ex=69d75ff0&is=69d60e70&hm=5c45fc9f326ee463542f28428d93a2b75811f71d5216cb28e82a723cd759b28c& https://cdn.discordapp.com/attachments/844600078948630559/1491350557007286333/Screenshot_2026-04-08_at_15.13.57.png?ex=69d75ff0&is=69d60e70&hm=39cca9ca10f5532799a44298ff1727a2bac2554e8b3c4aba3fb1d9979a82e949&
3 Views