
Rewriting Aggregate Awareness for Better Optimization
A behind-the-flag rewrite moves aggregate awareness optimization to a simpler Omni algebra layer. The demo explains improvements to level-of-detail support and date-fill queries, including…
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
This is a kind of demo for professionals. We've made many improvements over the past few months to the aggregated awareness feature. So here we have a query that uses a detail field. This is just an example of a fix we made. This is the detail field. Previously, it didn't work at all with aggregated awareness. Now, as you can see, everything works.
We have this comment that was written. We spent a lot of time fixing such errors with aggregated awareness. The reason they are difficult to fix is that this commented SQL is actually the SQL we write for detail. It has this join. The previous implementation of aggregate awareness was based on relational algebra, corresponding to this more complex SQL, and had to restore the underlying form for optimization.
So what we've done here, and the big change we're working on, is if we have another Omni SQL where everything is simpler. We see that there is only one main select, or more than one with detail. The detailing is complex, but it is much simpler, and the relational algebra is much simpler. So we rewrote the aggregate awareness code, which still runs through the model flag, to work at this simpler Omni algebra level.
So, let me just show you an example of what comes out of this rewrite. There's existing aggregate awareness where if we have a fill here, and there's no range in the state filter, the code knows how to get the bounds. You can see this if you look closely . This is in the unoptimized code for performing fill.
Here we see the optimization of aggregated awareness. This is the old version without the checkbox enabled, but you have to look very closely. He was actually reading the fact table to get the limits, which is not good, because that's the point. We actually scanned this potentially huge table to retrieve two rows. And now, with the checkbox enabled, if I enable this in the workbook model and come back here, we'll see, you'll have to look really closely because there's a dummy aggregation table there , but, uh, you'll just have to take my word for it.
Now this is, uh, a selection from the aggregation table from start to finish. Uh, and this is not what was planned, it's just a result of how things work, because essentially we optimized at this level, uh, added an aggregation table, and then did further rewrites to achieve all this complexity for filling. So this is kind of a deep feature that's still a work in progress, and it's hard to see the result directly, but hopefully it will mean that awareness of aggregates will be easier to maintain over time, and we can build other things into it, like cubes , with better coverage, especially of new features and edge cases.
That's all.