We are trying to use Filters for our multi-tenant database, and have problems for two reasons. 1 - Filters are not universally applied to all styles of generated queries - correct query results, but big performance problem. 2 - Filter criteria are not applied at the join, but in the where clause (known issue - https://nhibernate.jira.com/browse/NH-1930) - potential incorrect query results, and big performance problem.
I am studying the code to see if I can come up with solutions that we can contribute. I am finding it challenging to get my head around the implementation to see where the rubber hits the road with these issues, as they are fairly fundamental. Any help focusing me on areas of the code would be appreciated. *Specific Question re item 1 above* - the fact that filters are not universally applied seems intentional, yet is a problem for multi-tenant filters and analogous data situations. Are there reasons it would be bad for them to be used in ALL affected queries when they are applied from the application? Would there therefore be a need to have a (session?) setting to keep the current behavior vs. making an applied filter "universal"? *Clarification of performance issue*: An Id / primary key is horribly inefficient in a database with hundreds to thousands of tenants as compared to using a multi-column tenant index (e.g. tenantid, id) - our worst case example so far with 100 tenants is 2 milliseconds vs 2 hours.
