Patent ID: 8478775

Claim:
A computer system having one or more processors for processing query requests in a manner that reduces computer resources used to process the requests, the computer system having one or more computer readable media storing computer-executable instructions that, when executed by the one or more processors, implement a method performed by the one or more processors, the method being comprised of: obtaining an external query request from an application, the external query request requesting to apply operations over a data set in at least one data store, including a windowing operation that defines a window of a subset of sorted and filtered data that is to be returned after both a filter operation and a sort operation are applied to the data set; splitting said external query request of the application into a first internal query request and a second internal query request, including: generating the first internal query request, which is configured to generate distribution statistics that are specific to said external query request by computing distribution statistics that are usable in determining what sorted and filtered data would be returned by the windowing operation, the distribution statistics being based on a distribution of rows of the data set after applying the filter operation of said external query request and columns which match the sort operation of said query request to the data set; and then executing the first internal query request to generate the distribution statistics; and using said distribution statistics that were generated specifically for the external query request to generate the second internal query request, the second internal query request being configured to: execute said filter and sort operations of the external query request while limiting the filter and sort operations to the subset of data defined by the windowing operation of the external query request such that sorting comprises sorting only the number of rows associated with the size of the requested window over the data set, and such that the second internal sub-request selects only the rows that match the window based on the distribution statistics; and return at least one result set for the external query request; executing the second internal query request to generate the at least one result set; and transmitting said at least one result set to the application.