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

2019-08-16 Thread Peter Grman
Hello Tom, yes, I think this query is right below the geqo_threshold. But as I said, when I change only the WHERE condition to use AND instead of OR it's resulting in a really fast and efficient query (same planning time, but ~1/500th-1/1000th execution time). So there should be something differen

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

2019-08-16 Thread Tom Lane
Peter Grman writes: > yes, I think this query is right below the geqo_threshold. But as I said, > when I change only the WHERE condition to use AND instead of OR it's > resulting in a really fast and efficient query (same planning time, but > ~1/500th-1/1000th execution time). So there should be s

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

2019-08-16 Thread Tom Lane
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 you're hitting the default join_collapse_limit. Increasing that setting might improve matters somewhat, though it won't fix the