DZone Database Zone
How to Avoid Excessive Sorts in Window Functions
Usually, this blog is 100% pro-window-functions and advocates using them for any occasion. But like any tool, window functions come at a price and we must carefully evaluate if that's a price we're willing to pay. That price can be a sort operation. And as we all know, sort operations are expensive. They follow O(n log n) complexity, which must be avoided at all costs for large datasets.
In a previous post, I've described how to calculate a running total with window functions (among other ways). In this post, we're going to calculate the cumulative revenue at each payment in our Sakila database.
No comments:
Post a Comment