Does Using Group By Field Before Sorting Ensure Good Performance in Multi-Tenant Collections?

Hi all,
I’m designing a NocoBase collection for a multi-tenant app and want to make sure sorting is both fast and properly scoped to each tenant. My current setup adds a tenant_id field (as a group by key) alongside an explicit sort field, but I’m concerned about performance if the sorting operation ends up including records from all tenants.
Does grouping by (e.g., filtering by tenant_id) before applying the sort operation guarantee that only the relevant rows are processed and sorted efficiently? Are there best practices for configuring fields and indexes in NocoBase for optimal performance with this pattern? I’m not using formula fields for sorting, just a regular integer sort column.
Any advice or real-world experience on how NocoBase handles this for collections with a large record count across multiple tenants would be greatly appreciated!
Thanks in advance.

Please check if this feature meets your needs.

Thanks for the reply. Multi space helps to segregate the data but it it’s not clear from the documentation how sort fields will be impacted. If there are 20 spaces and each has 1000 records in a table that contains a sort field, what happens? Are all 20,000 records sorted each time a change is made? If so, this will have an impact on performance.

In multi-space systems, data is isolated first and then sorted.