# US 12,007,987 B1 · Sort optimization

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

- Number: US 12,007,987 B1
- Document ID: US12007987B1
- Status: Granted
- Kind: B1
- Application number: 18/063,852
- Filed: 2022-12-09
- Granted: 2024-06-11
- Earliest claimed: 2020-11-25
- Assignees: Progress Software Corporation
- Applicants: Progress Software Corporation
- Inventors: Mohammed Sayeed Akthar; Sunil Jardosh
- Web page: https://patentgrep.com/patent/US12007987B1

## CPC

- G06F 16/244: {Grouping and aggregation}
- G06F 16/221: {Column-oriented storage; Management thereof}
- G06F 16/2282: {Tablespace storage structures; Management thereof}
- G06F 16/2445: {Data retrieval commands; View definitions}
- G06F 16/24532: {of parallel queries}
- G06F 16/24535: {of sub-queries or views}
- G06F 16/24537: {of operators}
- G06F 16/24542: {Plan optimisation}
- G06F 16/284: {Relational databases}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A system and method for processing of queries including receiving a query including a set operation and a sort operation, wherein the set operation includes a first data structure and a second data structure and the sort operation requests a result set that is sorted based on a column or attribute of the first data structure and a column or attribute of the second data structure; generating a query plan in which a sort operation occurs prior to the set operation; determining a first, partial set of one or more resultant rows responsive to the query; sending the first, partial set of one or more resultant rows responsive to the query to a client; determining a second, partial set of one or more resultant rows responsive to the query; and sending the second, partial set of one or more resultant rows to the client.

## Claims

### Claim 1

A computer-implemented method comprising:
receiving, using one or more processors, a query including a set operation and a sort operation, wherein the set operation includes a first data structure and a second data structure and the sort operation requests a result set that is sorted based on a first column or attribute of the first data structure and a second column or attribute of the second data structure, wherein the first column or attribute and the second column or attribute are specified in the sort operation, wherein the first column or attribute and the second column or attribute are distinct, and wherein the set operation and the sort operation are distinct, explicit operations within the query;
generating, using the one or more processors, a query plan in which the sort operation occurs prior to the set operation;
determining, using the one or more processors, a set of one or more resultant rows responsive to the query; and
sending, using the one or more processors, the set of one or more resultant rows responsive to the query to a client.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1 including:
determining, using the one or more processors, another set of one or more resultant rows responsive to the query; and
sending, using the one or more processors, the another set of one or more resultant rows responsive to the query to the client.

### Claim 3 (depends on 2)

The computer-implemented method of claim 2, wherein a full result set comprises the set of one or more resultant rows responsive to the query, and the another set of one or more resultant rows responsive to the query.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, wherein determining the set of one or more resultant rows responsive to the query includes:
buffering a first portion of the set of one or more resultant rows; and
merging a second portion of the set of one or more resultant rows to the first portion of the set of one or more resultant rows in the buffer,
wherein the first portion and second portion of the set of one or more resultant rows have a common value in the first column or attribute of the first data structure on which the sort operation is requested.

### Claim 5 (depends on 4)

The computer-implemented method of claim 4 including:
reading a row from the first data structure;
determining the row from the first data structure has a different value in the first column or attribute of the first data structure on which the sort operation is requested;
responsive to determining the row from the first data structure has different value in the first column or attribute of the first data structure and after merging the second portion of the set of one or more resultant rows to the first portion of the set of one or more resultant rows in the buffer, sending the first portion and second portion of the set of one or more resultant rows, as the set of one or more resultant rows; and
clearing the buffer.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1 including:
determining, using the one or more processors, whether the first column or attribute of the first data structure has an index of the first data structure defined on it; and
determining, using the one or more processors, whether the second column or attribute of the second data structure has an index of the second data structure defined on it.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, wherein the first data structure and the second data structure are relational tables.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, wherein the first data structure and the second data structure are non-relational data structures.

### Claim 9 (depends on 1)

The computer-implemented method of claim 1, wherein the query uses structured query language (SQL).

### Claim 10 (depends on 1)

The computer-implemented method of claim 1, wherein the set operation is one or more of an inner join, left outer join, right outer join, full outer join and cross join.

### Claim 11

A system comprising:
one or more processors; and
a memory storing instructions that, when executed by the one or more processors, cause the system to:
receive a query including a set operation and a sort operation, wherein the set operation includes a first data structure and a second data structure and the sort operation requests a result set that is sorted based on a first column or attribute of the first data structure and a second column or attribute of the second data structure, wherein the first column or attribute and the second column or attribute are specified in the sort operation, wherein the first column or attribute and the second column or attribute are distinct, and wherein the set operation and the sort operation are distinct, explicit operations within the query;
generate a query plan in which the sort operation occurs prior to the set operation;
determine a set of one or more resultant rows responsive to the query; and
send the set of one or more resultant rows responsive to the query to a client.

### Claim 12 (depends on 11)

The system of claim 11, wherein the instructions, when executed by the one or more processors, cause the system to:
determining, using the one or more processors, another set of one or more resultant rows responsive to the query; and
sending, using the one or more processors, the another set of one or more resultant rows responsive to the query to the client.

### Claim 13 (depends on 12)

The system of claim 12, wherein a full result set comprises the set of one or more resultant rows responsive to the query, and the another set of one or more resultant rows responsive to the query.

### Claim 14 (depends on 11)

The system of claim 11, wherein determining the set of one or more resultant rows responsive to the query includes:
buffering a first portion of the set of one or more resultant rows; and
merging a second portion of the set of one or more resultant rows to the first portion of the set of one or more resultant rows in the buffer,
wherein the first portion and second portion of the set of one or more resultant rows have a common value in the first column or attribute of the first data structure on which the sort operation is requested.

### Claim 15 (depends on 14)

The system of claim 14, wherein the instructions, when executed by the one or more processors, cause the system to:
read a row from the first data structure;
determine the row from the first data structure has a different value in the first column or attribute of the first data structure on which the sort operation is requested;
responsive to determining the row from the first data structure has different value in the first column or attribute of the first data structure and after merging the second portion of the set of one or more resultant rows to the first portion of the set of one or more resultant rows in the buffer, send the first portion and second portion of the set of one or more resultant rows, as the set of one or more resultant rows; and
clear the buffer.

### Claim 16 (depends on 11)

The system of claim 11, wherein the instructions, when executed by the one or more processors, cause the system to:
determine whether the first column or attribute of the first data structure has an index of the first data structure defined on it; and
determine whether the second column or attribute of the second data structure has an index of the second data structure defined on it.

### Claim 17 (depends on 11)

The system of claim 11, wherein the first data structure and the second data structure are relational tables.

### Claim 18 (depends on 11)

The system of claim 11, wherein the first data structure and the second data structure are non-relational data structures.

### Claim 19 (depends on 11)

The system of claim 11, wherein the query uses structured query language (SQL).

### Claim 20 (depends on 11)

The system of claim 11, wherein the set operation is one or more of an inner join, left outer join, right outer join, full outer join and cross join.
