Re: Bad Estimate for multi tenant database queries

2019-09-04 Thread Peter Grman
Hello Michael, I digged a bit deeper and found an even simpler query, which can perfectly embody that problem: explain (ANALYZE, FORMAT text) select * from "Reservation"."Reservation" r join "Rates"."TimeSliceDefinition" t on r."TimeSliceDefinitionId" = t."Id" where r."AccountCode" = 'OXHV' and t

Bad Estimate for multi tenant database queries

2019-08-30 Thread Peter Grman
Hello, I've noticed that we our queries have very bad estimates, which leads to the planner using slow nested loops, here is a subset of the query without tenant separation (correct estimates): explain (ANALYZE, COSTS, BUFFERS, FORMAT text) select * from "Reservation"."Reservation" r

Re: Bad Estimate for complex query with JOINS on subselects and OR in where conditions

2019-08-16 Thread Peter Grman
thing different, or? Thx for taking your time! On Fri, Aug 16, 2019 at 3:44 PM Tom Lane wrote: > Peter Grman writes: > > our ORM with tenant separation enabled is creating the following query: > > Ugh. > > By my count there are nine joined tables in that query, which means &g