# US 2025/0165467 A1 · Large language model-based data query optimization

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

- Number: US 2025/0165467 A1
- Document ID: US20250165467A1
- Status: Published application
- Kind: A1
- Application number: 18/511,261
- Filed: 2023-11-16
- Published: 2025-05-22
- Earliest claimed: 2023-11-16
- Assignees: Paypal, Inc.
- Applicants: Paypal, Inc.
- Inventors: Anxu Zhang; Ping Wu; Jiake Chen
- Web page: https://patentgrep.com/patent/US20250165467A1

## CPC

- G06F 16/24532: {of parallel queries}
- G06F 16/2456: {Join operations}
- G06F 16/248: Presentation of query results
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Methods and systems are presented for providing a large language model-based query optimizer to interface between program developers and database systems. The query optimizer receives programming code corresponding to a set of queries intended for a database system from a program developer. The query optimizer then uses a machine learning model to analyze the programming code and to determine a set of strategies for executing the set of data queries corresponding to the programming code. To determine the set of strategies, the machine learning model analyzes dependencies among the set of data queries and retrieves sample data from the database system. The machine learning model implement the set of strategies by incorporating additional instructions in the programming code for the database system such that the database system would execute the set of data queries according to the set of strategies.

## Claims

### Claim 1

A system, comprising:
a non-transitory memory; and
one or more hardware processors coupled with the non-transitory memory and configured to read instructions from the non-transitory memory to cause the system to perform operations comprising:
receiving, by a query optimizer module, programming code for querying data from a database system;
decomposing, by a machine learning model, the programming code into a plurality of query tasks;
obtaining, by the machine learning model, a portion of the data from the database system;
analyzing, by the machine learning model, data characteristics associated with the portion of the data obtained from the database system;
determining, by the machine learning model, a set of strategies for executing the plurality of query tasks in the database system based on the analyzing the data characteristics of the portion of the data;
modifying, by the machine learning model, the programming code according to the set of strategies;
configuring, by the machine learning model, the database system to execute the modified programming code for querying the data from the database system;
obtaining, by the machine learning model, a query result from the database system; and
generating, by the query optimizer module, a response based on the query result.

### Claim 2 (depends on 1)

The system of claim 1, wherein the portion of the data corresponds to a percentage of the data below a threshold percentage.

### Claim 3 (depends on 1)

The system of claim 1, wherein the operations further comprise:
analyzing the programming code, wherein the decomposing the programming code into the plurality of query tasks is based on the analyzing the programming code.

### Claim 4 (depends on 1)

The system of claim 1, wherein the operations further comprise:
incorporating a set of parameters into the programming code, wherein the set of parameters comprises at least one of a block size parameter specifying a block size of a file or a data skew parameter indicating whether a data skew condition exists in the data being queried.

### Claim 5 (depends on 1)

The system of claim 1, wherein the set of strategies comprises an execution strategy that specifies at least one of a parallel execution of two or more query tasks in the plurality of query tasks or a sequential execution of the two or more query tasks in the plurality of query tasks.

### Claim 6 (depends on 1)

The system of claim 1, wherein the set of strategies comprises an execution strategy that specifies an order for executing the plurality of query tasks.

### Claim 7 (depends on 1)

The system of claim 1, wherein the machine learning model is configured to determine one or more dependencies among the plurality of query tasks, and wherein the set of strategies is determined based on the one or more dependencies.

### Claim 8

A method comprising:
receiving, by a query optimizer module of a computer system, programming code for querying data from a database system;
decomposing, by a machine learning model executing on the computer system, the programming code into a plurality of query tasks;
obtaining, by the machine learning model, sample data representing a portion of the data from the database system;
determining, by the machine learning model, data characteristics associated with the sample data obtained from the database system;
determining, by the machine learning model, a set of strategies for executing the plurality of query tasks in the database system based on the data characteristics;
modifying, by the machine learning model, the programming code according to the set of strategies, wherein the modifying comprises incorporating the set of strategies into the programming code;
providing, by the machine learning model, the modified programming code to the database system, wherein the providing the modified programming code causes the database system to execute the plurality of query tasks according to the set of strategies;
obtaining, by the machine learning model, a query result from the database system; and
generating, by the query optimizer module, a response based on the query result.

### Claim 9 (depends on 8)

The method of claim 8, wherein the plurality of query tasks comprises at least one of a table creation task for creating a table based on the data queried from the distributed database system, a join task for joining a plurality of tables created based on the data, or an operation task for performing one or more operations on the data.

### Claim 10 (depends on 8)

The method of claim 8, further comprising:
analyzing the programming code, wherein the decomposing the programming code into the plurality of query tasks is based on the analyzing the programming code.

### Claim 11 (depends on 8)

The method of claim 8, wherein the response represents the query result and the set of strategies used to query the data from the database system, and wherein the method further comprises providing the response to a device.

### Claim 12 (depends on 8)

The method of claim 8, further comprising:
generating, by the machine learning model, second programming code for retrieving the sample data from the database system.

### Claim 13 (depends on 8)

The method of claim 8, further comprising:
analyzing, by the machine learning model, the sample data, wherein the determining the data characteristics is based on the analyzing the sample data.

### Claim 14 (depends on 8)

The method of claim 8, further comprising:
generating, by the machine learning model, a plurality of parameters for implementing the set of strategies; and
incorporating, by the machine learning model, the plurality of parameters into the programming code.

### Claim 15

A non-transitory machine-readable medium having stored thereon machine-readable instructions executable to cause a machine to perform operations comprising:
determining, by a query optimizer module of the machine and based on analyzing programming code received from a user device, that the programming code corresponds to a plurality of data queries intended for a database system;
obtaining, by a machine learning model executed on the machine, sample data from the database system based on the plurality of data queries;
determining, by the machine learning model, data characteristics associated with the sample data obtained from the database system;
determining, by the machine learning model, a set of strategies for executing the plurality of data queries against the database system based on the data characteristics;
implementing, by the machine learning model, the set of strategies, wherein the implementing comprises modifying the programming code to include additional instructions corresponding to the set of strategies;
configuring, by the machine learning model, the database system to execute the plurality of data queries according to the set of strategies based on the modified programming code;
obtaining, by the machine learning model, a query result from the database system; and
generating, by the query optimizer module, a response based on the query result.

### Claim 16 (depends on 15)

The non-transitory machine-readable medium of claim 15, wherein the operations further comprise:
analyzing the sample data, wherein the determining the data characteristics is based on the analyzing the sample data.

### Claim 17 (depends on 15)

The non-transitory machine-readable medium of claim 15, wherein the operations further comprise:
generating second programming code for retrieving the sample data from the database system.

### Claim 18 (depends on 15)

The non-transitory machine-readable medium of claim 15, wherein the set of strategies comprises an execution strategy that specifies a hierarchical order for executing the plurality of data queries.

### Claim 19 (depends on 15)

The non-transitory machine-readable medium of claim 15, wherein the set of strategies comprises a processing strategy that specifies additional processing to be performed when executing a particular data query in the plurality of data queries.

### Claim 20 (depends on 15)

The non-transitory machine-readable medium of claim 15, wherein the response represents the query result and the set of strategies used to execute the plurality of data queries at the database system, and wherein the operations further comprise providing the response to the user device.
