# US 2025/0156418 A1 · Techniques to improve query performance using dynamic filtering based on left-join aggregation pattern

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

- Number: US 2025/0156418 A1
- Document ID: US20250156418A1
- Status: Published application
- Kind: A1
- Application number: 18/508,460
- Filed: 2023-11-14
- Published: 2025-05-15
- Earliest claimed: 2023-11-14
- Assignees: Workday, Inc.
- Applicants: Workday, Inc.
- Inventors: Hanumath Rao MADURI; Karthik RAJAGOPAL; Gary HECK
- Web page: https://patentgrep.com/patent/US20250156418A1

## CPC

- G06F 16/24544: {Join order optimisation}
- G06F 16/24537: {of operators}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In some implementations, the techniques described herein relate to a method including: receiving, by a query engine, a database query, the database query including an inner query having inner query conditions and an outer query having outer query conditions; determining, by the query engine, that a number of rows responsive to the outer query exceeds a threshold; determining, by the query engine, that the inner query conditions and the outer query conditions are correlated; rewriting, by the query engine, the inner query conditions to include at least one of the outer query conditions to generate an optimized query; and executing, by the query engine, the optimized query on a database.

## Claims

### Claim 1

A method comprising:
receiving, by a query engine, a database query, the database query including an inner query having inner query conditions and an outer query having outer query conditions;
determining, by the query engine, that a number of rows responsive to the outer query exceeds a threshold;
determining, by the query engine, that the inner query conditions and the outer query conditions are correlated;
rewriting, by the query engine, the inner query conditions to include at least one of the outer query conditions to generate an optimized query; and
executing, by the query engine, the optimized query on a database.

### Claim 2 (depends on 1)

The method of claim 1, wherein receiving a database query comprises receiving a structured query language (SQL) statement.

### Claim 3 (depends on 1)

The method of claim 1, wherein determining that the number of rows responsive to the outer query exceeds a threshold comprises replacing a select list of the outer query to generate a second query and executing the second query on a database.

### Claim 4 (depends on 3)

The method of claim 3, wherein replacing the select list comprises replacing the inner query of the database query with a COUNT operation.

### Claim 5 (depends on 1)

The method of claim 1, wherein determining that the number of rows responsive to the outer query exceeds a threshold comprises computing a ratio of the number of rows responsive to the outer query to a total size of an outer table queried by the outer query.

### Claim 6 (depends on 1)

The method of claim 1, wherein determining that the inner query conditions and the outer query conditions are correlated comprises identifying a joining condition in the inner query.

### Claim 7 (depends on 1)

The method of claim 1, wherein rewriting the inner query conditions to include at least one of the outer query conditions to generate an optimized query comprises executing the outer query, modifying the inner query conditions to generate a new inner query, executing the new inner query, and joining results of the new inner query with results of the outer query.

### Claim 8

A non-transitory computer-readable storage medium for tangibly storing computer program instructions capable of being executed by a computer processor, the computer program instructions defining steps of:
receiving, by a query engine, a database query, the database query including an inner query having inner query conditions and an outer query having outer query conditions;
determining, by the query engine, that a number of rows responsive to the outer query exceeds a threshold;
determining, by the query engine, that the inner query conditions and the outer query conditions are correlated;
rewriting, by the query engine, the inner query conditions to include at least one of the outer query conditions to generate an optimized query; and
executing, by the query engine, the optimized query on a database.

### Claim 9 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein receiving a database query comprises receiving a structured query language (SQL) statement.

### Claim 10 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein determining that the number of rows responsive to the outer query exceeds a threshold comprises replacing a select list of the outer query to generate a second query and executing the second query on a database.

### Claim 11 (depends on 10)

The non-transitory computer-readable storage medium of claim 10, wherein replacing the select list comprises replacing the inner query of the database query with a COUNT operation.

### Claim 12 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein determining that the number of rows responsive to the outer query exceeds a threshold comprises computing a ratio of the number of rows responsive to the outer query to a total size of an outer table queried by the outer query.

### Claim 13 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein determining that the inner query conditions and the outer query conditions are correlated comprises identifying a joining condition in the inner query.

### Claim 14 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein rewriting the inner query conditions to include at least one of the outer query conditions to generate an optimized query comprises executing the outer query, modifying the inner query conditions to generate a new inner query, executing the new inner query, and joining results of the new inner query with results of the outer query.

### Claim 15

A device comprising:
a processor; and
a storage medium for tangibly storing program logic for execution by the processor, the program logic comprising:
logic, executed by the processor, for receiving a database query, the database query including an inner query having inner query conditions and an outer query having outer query conditions,
logic, executed by the processor, for determining that a number of rows responsive to the outer query exceeds a threshold,
logic, executed by the processor, for determining that the inner query conditions and the outer query conditions are correlated,
logic, executed by the processor, for rewriting the inner query conditions to include at least one of the outer query conditions to generate an optimized query, and
logic, executed by the processor, for executing the optimized query on a database.

### Claim 16 (depends on 15)

The device of claim 15, wherein receiving a database query comprises receiving a structured query language (SQL) statement.

### Claim 17 (depends on 15)

The device of claim 15, wherein determining that the number of rows responsive to the outer query exceeds a threshold comprises replacing a select list of the outer query to generate a second query and executing the second query on a database.

### Claim 18 (depends on 17)

The device of claim 17, wherein replacing the select list comprises replacing the inner query of the database query with a COUNT operation.

### Claim 19 (depends on 15)

The device of claim 15, wherein determining that the number of rows responsive to the outer query exceeds a threshold comprises computing a ratio of the number of rows responsive to the outer query to a total size of an outer table queried by the outer query.

### Claim 20 (depends on 15)

The device of claim 15, wherein determining that the inner query conditions and the outer query conditions are correlated comprises identifying a joining condition in the inner query.
