US 12,072,881 B2
Key range query optimization
Kadir Ozdemir, San Jose, CA (US); and Tanuj Khurana, Kirkland, WA (US)
Assigned to Salesforce, Inc., San Francisco, CA (US)
Filed by Salesforce, Inc., San Francisco, CA (US)
Filed on Jan. 6, 2023, as Appl. No. 18/151,280.
Prior Publication US 2024/0232194 A1, Jul. 11, 2024
Int. Cl. G06F 16/24 (2019.01); G06F 16/242 (2019.01); G06F 16/245 (2019.01); G06F 16/2453 (2019.01)
CPC G06F 16/24542 (2019.01) [G06F 16/2445 (2019.01)] 18 Claims
OG exemplary drawing
 
1. A method for deriving a set of key ranges to be used in processing a database query, the method comprising:
receiving, by a computer system, the database query to execute against a database having a database table that includes a plurality of records associated with a plurality of keys, respectively, the database query specifying a set of conditional expressions that affect which ones of the plurality of records are returned, wherein the set of conditional expressions includes an IN expression;
based on the set of conditional expressions, deriving, by the computer system, the set of key ranges by:
representing the set of conditional expressions as a set of key spaces, wherein a particular key space encompasses ones of the plurality of keys that satisfy a particular one of the set of conditional expressions, wherein the representing includes converting the IN expression into at least one OR operation involving a pair of the set of key spaces;
performing a set of logical operations on pairs of the set of key spaces to reduce a number of key spaces in the set of key spaces; and
converting the set of key spaces into the set of key ranges after performing the set of logical operations; and
executing, by the computer system, the database query according to a query plan having the set of key ranges.