1. A method comprising: generating an execution plan for a database statement issued against a plurality of rows comprising a plurality of columns, where said database statement specifies a window function and specifies for said window function, a partition-by key of said plurality of columns and an order-by key of said plurality of columns; determining a number of sort operators to be included in said execution plan; determining a distribution key based at least in part on the partition-by key and the order-by key; determining, based on the distribution key, a plurality of mutually exclusive ranges; and determining, based at least in part on the plurality of mutually exclusive ranges, a distribution function for distributing each row of the plurality of rows to a respective specific sort operator of said sort operators based on values of the partition-by key and the order-by key of said each row; wherein the method is performed by one or more computing devices.