Optimizing execution of expensive subqueries

2018-07-11 Thread Mathieu Fenniak
othertbl WHERE anothertbl.UserId = tbl.UserId AND anothertbl.ThingyId = 1) as Thingy1Sum, ... repeat for multiply thingies ... FROM cte; Thanks for any thoughts you have, Mathieu Fenniak

Re: Optimizing execution of expensive subqueries

2018-07-13 Thread Mathieu Fenniak
anothertbl > WHERE anothertbl.UserId = tbl.UserId AND anothertbl.ThingyId = 1 > group by 1) as b on tbl.UserId=b.UserId > ORDER BY tbl.field1 LIMIT 20 > > > El mié., 11 de jul. de 2018 a la(s) 09:25, Mathieu Fenniak ( > mathieu.fenn...@replicon.com) escribió: > >> Hi pgsql-gene

Re: Complex filters -> Bad row estimates -> bad query plan

2019-08-21 Thread Mathieu Fenniak
Thanks Michael. I'll give some join alternatives a shot first... but, that's cool. What about OFFSET 0 makes this approach work? I'm thinking the OFFSET 0 create an optimization barrier that prevents the planner from collapsing that sub-query into the top query, and enforces ordering in the

Complex filters -> Bad row estimates -> bad query plan

2019-08-21 Thread Mathieu Fenniak
Hi all, I have a database query where I have a number of "simple" where clauses, a number of "complex" subquery based where clauses, and one NOT EXISTS where clause; it looks something like this: SELECT ...some fields... FROM Table1 WHERE Field1 IN (1, 2, 3, 4, 21, 24) AND -- simple filter