3 ms·
No, it is not a judgement call. The query planner should be storing the distributions of the values in every index. This makes it obvious which pushdown to do h
by HDThoreaun 1y ago
No, it is not a judgement call. The query planner should be storing the distributions of the values in every index. This makes it obvious which pushdown to do here. Again, basic stuff. Youre right though not quite simple as "push down as much as possible", it is one step past that.
- jmalicki 1y agoWithout storing the joint distribution of the values corresponding to the conditions that span multiple tables, it can be hard to know what's a win.
- Seattle3503 1y agoPostgres by default computes univariate stats for each column and uses those. If this is producing bad query plans, you can extend the statistics to be multivariate for select groups of columns manually. But to avoid combinatorially growth of stats related storage and work, you have to pick the columns by hand.
- jmalicki 1y agoThat still isn't multivariate stats across a join.
- Jupe 1y agoAgreed. Isn't this precisely why key statistics (table statistics) are maintained in many DB systems? Essentially, always "push down" the predicate with the worst statistics and always execute (early) the predicates with high selectivity. I'd be very surprised if virtually every RDBMS doesn't do this already.