US 11,880,369 B1
Pruning data based on state of top K operator
Max Heimel, Berlin (DE); Ismail Oukid, Berlin (DE); Linnea Passing, Berlin (DE); Stefan Richter, Berlin (DE); and Juliane K. Waack, Berlin (DE)
Assigned to Snowflake Inc., Bozeman, MT (US)
Filed by Snowflake Inc., Bozeman, MT (US)
Filed on Nov. 21, 2022, as Appl. No. 18/057,563.
Int. Cl. G06F 16/2455 (2019.01); G06F 16/2457 (2019.01)
CPC G06F 16/24557 (2019.01) [G06F 16/24578 (2019.01)] 30 Claims
OG exemplary drawing
 
1. A method comprising:
receiving a top K query directed at a table organized into multiple storage units, the top K query comprising a first clause to sort a result set in an order and a second clause that specifies that the result set is limited to a specific number of rows from the table;
identifying, by a table scan operator, a first set of rows from the table based on a scan set determined for the table based on the top K query, the scan set comprising one or more storage units from among the multiple storage units, the first set of rows having the specific number of rows;
providing, by the table scan operator, the first set of rows to a top K operator;
determining, by the top K operator, a current boundary based on the first set of rows;
providing, by the top K operator, the current boundary to the table scan operator;
pruning, by the table scan operator, the scan set based on the current boundary; and
identifying, by the table scan operator, a second set of rows from the table based on the pruning of the scan set; and
providing a result set responsive to the top K query based on the first and second set of rows, the result set being limited to the specific number of rows specified by the second clause of the top K query.