# US 2025/0165470 A1 · Database Query Optimization Via Parameter-Sensitive Plan Selection

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0165470 A1
- Document ID: US20250165470A1
- Status: Published application
- Kind: A1
- Application number: 19/035,387
- Filed: 2025-01-23
- Published: 2025-05-22
- Earliest claimed: 2021-11-16
- Assignees: Google Inc.
- Applicants: Google LLC
- Inventors: Lyric Pankaj Doshi; Eugene Brevdo; Campbell Bryce Fraser
- Web page: https://patentgrep.com/patent/US20250165470A1

## CPC

- G06F 16/24542: {Plan optimisation}
- G06F 11/3419: {by assessing time}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method includes receiving a database query requesting a database to conditionally return one or more data blocks. The database is stored on memory hardware in communication with the data processing hardware and the database query includes a plurality of parameters characterizing the database query. The method includes generating a set of query plans. Each query plan in the set of query plans is configured to execute the database query using a different order of operations. The method includes training a model using historical database queries and generating, using the trained model, a query plan score for each query plan in the set of query plans. The method includes selecting, using the query plan score of each query plan in the set of query plans, a query plan from the set of query plans. The method also includes executing the database query using the selected query plan.

## Claims

### Claim 1

A computer-implemented method executed by data processing hardware that causes the data processing hardware to perform operations comprising:
receiving a database query;
generating, based on the database query, a set of query plans each configured to execute the database query;
for each respective query plan in the set of query plans, determining, using a trained model, a corresponding query plan score;
selecting, based on the corresponding query plan score determined for each respective query plan, a respective one of the query plans from the set of query plans; and
executing the database query using the respective one of the query plans.

### Claim 2 (depends on 1)

The method of claim 1, wherein the database query comprises a Structured Query Language (SQL) query.

### Claim 3 (depends on 1)

The method of claim 1, wherein generating the set of query plans comprises generating the set of query plans using a database query planner.

### Claim 4 (depends on 1)

The method of claim 1, wherein selecting the respective one of the query plans is based on an amount of memory available or an amount of cache available.

### Claim 5 (depends on 1)

The method of claim 1, wherein selecting the respective one of the query plans is based on a predicted latency of each query plan of the set of query plans.

### Claim 6 (depends on 5)

The method of claim 5, wherein the predicted latency comprises a tail latency.

### Claim 7 (depends on 1)

The method of claim 1, wherein selecting the respective one of the query plans is based on a predicted resource usage of each query plan of the set of query plans.

### Claim 8 (depends on 1)

The method of claim 1, wherein:
each query plan of the set of query plans comprises a hint string; and
selecting the respective one of the query plans is based on the hint string of each query plan of the set of query plans.

### Claim 9 (depends on 1)

The method of claim 1, wherein the operations further comprise, prior to generating the set of query plans, selecting a query template from a set of query templates.

### Claim 10 (depends on 9)

The method of claim 9, wherein generating the set of query plans comprises generating the set of query plans using the selected query template.

### Claim 11

A system comprising:
data processing hardware; and
memory hardware in communication with the data processing hardware, the memory hardware storing instructions that when executed on the data processing hardware cause the data processing hardware to perform operations comprising:
receiving a database query;
generating, based on the database query, a set of query plans each configured to execute the database query;
for each respective query plan in the set of query plans, determining, using a trained model, a corresponding query plan score;
selecting, based on the corresponding query plan score determined for each respective query plan, a respective one of the query plans from the set of query plans; and
executing the database query using the respective one of the query plans.

### Claim 12 (depends on 11)

The system of claim 11, wherein the database query comprises a Structured Query Language (SQL) query.

### Claim 13 (depends on 11)

The system of claim 11, wherein generating the set of query plans comprises generating the set of query plans using a database query planner.

### Claim 14 (depends on 11)

The system of claim 11, wherein selecting the respective one of the query plans is based on an amount of memory available or an amount of cache available.

### Claim 15 (depends on 11)

The system of claim 11, wherein selecting the respective one of the query plans is based on a predicted latency of each query plan of the set of query plans.

### Claim 16 (depends on 15)

The system of claim 15, wherein the predicted latency comprises a tail latency.

### Claim 17 (depends on 11)

The system of claim 11, wherein selecting the respective one of the query plans is based on a predicted resource usage of each query plan of the set of query plans.

### Claim 18 (depends on 11)

The system of claim 11, wherein:
each query plan of the set of query plans comprises a hint string; and
selecting the respective one of the query plans is based on the hint string of each query plan of the set of query plans.

### Claim 19 (depends on 11)

The system of claim 11, wherein the operations further comprise, prior to generating the set of query plans, selecting a query template from a set of query templates.

### Claim 20 (depends on 19)

The system of claim 19, wherein generating the set of query plans comprises generating the set of query plans using the selected query template.
