# US 2008/0288446 A1 · Queries with soft time constraints

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

- Number: US 2008/0288446 A1
- Document ID: US20080288446A1
- Status: Published application
- Kind: A1
- Application number: 11/804,502
- Filed: 2007-05-18
- Published: 2008-11-20
- Earliest claimed: 2007-05-18
- Assignees: Oracle International Corporation
- Inventors: Ying Hu; Seema Sundara; Jagannathan Srinivasan
- Web page: https://patentgrep.com/patent/US20080288446A1

## CPC

- G06F 16/2462: {Approximate or statistical queries}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems, methodologies, media, and other embodiments associated with supporting queries with soft time constraints are described. One exemplary system embodiment includes logic for accepting a query having a soft time constraint. The example system may also include logic for rewriting the query having the soft time constraint into a query having a row limitation or a sample percentage limitation. In one example, the row limitation or sample percentage limitation are computed by repetitively comparing an estimated query execution time to the soft time constraint.

## Claims

### Claim 1

A system, comprising:
a receive logic to receive a first query having a soft time constraint;
an analytics logic to provide a predicted execution time for a query; and
a constraint rewrite logic to selectively produce a rewritten query based on the first query, the rewritten query having a restricted result clause, where the restricted result clause depends, at least in part, on the predicted execution time.

### Claim 2 (depends on 1)

The system of claim 1, the soft time constraint being a desired upper bound for execution time of the rewritten query.

### Claim 3 (depends on 2)

The system of claim 2, the soft time constraint being one of, a numerical value representing a number of seconds, an expression that evaluates to a number of seconds, and a clock time by which the rewritten query is to complete.

### Claim 4 (depends on 1)

The system of claim 1, the first query also having an acceptable nature of results constraint.

### Claim 5 (depends on 4)

The system of claim 4, where the acceptable nature of results constraint specifies one of, whether a partial result is to be returned in response to the execution of the rewritten query, and whether an approximate result is to be returned in response to the execution of the rewritten query.

### Claim 6 (depends on 5)

The system of claim 5, where the restricted result clause in the rewritten query specifies one of, a number of rows to which row selection is to be limited by the rewritten query, and a sample percentage to which row selection is to be limited by the rewritten query.

### Claim 7 (depends on 6)

The system of claim 6, where the constraint rewrite logic is to iteratively:
choose different candidate numbers of rows to be selected;
determine a set of predicted execution times associated with queries limited to the candidate numbers of rows; and
manipulate the rewritten query to include a row number clause to cause a limited number of rows to be selected, where the row number clause is based on a relation between a member of the set of predicted execution times and the soft time constraint.

### Claim 8 (depends on 7)

The system of claim 7, where the constraint rewrite logic is to choose the different candidate numbers of rows by root finding.

### Claim 9 (depends on 8)

The system of claim 8, where the root finding solves for a root of FQ(R)−T=0, where:
FQ(R) represents the execution time for the rewritten query using the specified result set size;
R represents the result set size; and
T represents the amount of time specified in the soft time constraint.

### Claim 10 (depends on 9)

The system of claim 9 where FQ(R) is an estimate provided by a database analytic tool.

### Claim 11 (depends on 1)

The system of claim 1, where the first query concerns two or more tables and where the constraint rewrite logic is to configure the rewritten query to divide a time available to execute the rewritten query substantially equally between the two or more tables.

### Claim 12 (depends on 6)

The system of claim 6, where the constraint rewrite logic is to iteratively:
choose different candidate sample percentages to control a number of rows to select;
determine a set of predicted execution times associated with queries limited by the candidate sample percentages; and
manipulate the rewritten query to include a sample clause to cause a limited number of rows to be provided in a sample, where the sample percentage is based on a relation between a member of the predicted execution times and the soft time constraint.

### Claim 13 (depends on 12)

The system of claim 12, where the constraint rewrite logic is to choose the different candidate sample percentages for a single table query using root finding.

### Claim 14 (depends on 13)

The system of claim 13, where the root finding solves for a root of FQ(S)−T=0, where:
FQ(S) represents the execution time for the rewritten query using the specified sample percentage;
S represents the sample percentage; and
T represents the amount of time specified in the soft time constraint.

### Claim 15 (depends on 14)

The system of claim 14, where FQ(S) is an estimate provided by a database analytic tool.

### Claim 16 (depends on 1)

The system of claim 1, where the first query involves a join on a foreign key of two tables, where the constraint rewrite logic is to identify a fact table and a non-fact table in the two tables, and where the constraint rewrite logic is to manipulate the rewritten query to first limit row selection in the fact table and then to join the results of the limited row selection to the non-fact table.

### Claim 17 (depends on 1)

The system of claim 1, where the first query involves a join of two tables not on a foreign key, and where the constraint rewrite logic is to manipulate the rewritten query to first limit row selection and then to join results of the limited row selection.

### Claim 18 (depends on 17)

The system of claim 17, where the constraint rewrite logic is to maximize f1*f2, where f1 represents the sample size of one of the two tables and f2 represents the sample size of the other of the two tables.

### Claim 19 (depends on 1)

The system of claim 1, where the first query includes one of, a hash join, and a sort-merge join, of a first table R1 and a second table R2, where f1 represents a sample size for R1 and f2 represents a sample size for R2, where T1 represents a time to process R1 and T2 represents a time to process R2, where S1 represents a sample of R1 and S2 represents a sample of R2, where t1 represents a time to process S1 and t2 represents a time to process S2; and
where the constraint rewrite logic is to produce the rewritten query so that t1=t2 and t1+t2< the time specified by the soft time constraint.

### Claim 20 (depends on 18)

The system of claim 18, where the first query includes a nested loop join and the constraint rewrite logic is to identify one of the two tables to join as an outer table and to identify one of the two tables to join as an inner table, the constraint rewrite to acquire a sample from the outer table, and then to join the sample from the outer table to the inner table.

### Claim 21 (depends on 1)

The system of claim 1, where the first query includes a union operation between a first table R1 and a second table R2, and where the constraint rewrite logic is to configure the rewritten query with a sample (R1, f1) union sample (R2, f2) clause with f1=f2, where f1 represents a sample size for R1 and f2 represents a sample size for R2.

### Claim 22 (depends on 1)

The system of claim 1, where the first query includes a difference operation between a first table R1 and a second table R2, and where the constraint rewrite logic is to configure the rewritten query with a sample (R1, f1) difference R2 clause, where f1 represents a sample size for R1.

### Claim 23 (depends on 1)

The system of claim 1, where the first query includes an intersection operation between a first table R1 and a second table R2, and where the constraint rewrite logic is to configure the rewritten query with a sample (R1, f1) intersect sample (R2, f2) clause, where f1*f2 is maximized, where f1 represents a sample size for R1 and f2 represents a sample size for R2.

### Claim 24 (depends on 1)

The system of claim 1, where the first query includes a sub-query.

### Claim 25 (depends on 24)

The system of claim 24, where the constraint rewrite logic is to produce the rewritten query so that a predicate in the sub-query is not sampled.

### Claim 26 (depends on 1)

The system of claim 1, including an aggregate function logic to provide an estimated aggregate function and a related confidence function.

### Claim 27 (depends on 26)

The system of claim 26, where the estimated aggregate function is one of, an estimated sum function, an estimated count function, and an estimated average function.

### Claim 28 (depends on 1)

The system of claim 1, where the system receives the first query from one or more of, a decision support system, a mobile network application, and a radio frequency identification application, and where the system provides results within a time period that satisfies a service level agreement.

### Claim 29

A computer-readable medium storing processor executable instructions that when executed by a processor cause the processor to perform a method, the method comprising:
receiving a first select statement having a soft time constraint clause, the select statement describing a desired selection of one or more rows from a set of tables;
determining an execution time estimate for the first select statement;
selecting from the set of tables a subset of tables from which row selection is to be limited, where the subset of tables is selected based, at least in part, on the soft time constraint clause and the execution time estimate;
selecting a method by which row selection from a member of the subset of tables is to be limited, where the method selected is based, at least in part, on the soft time constraint clause and the execution time estimate;
selecting an amount by which row selection from a member of the subset of tables is to be limited, where the amount selected is based, at least in part, on the soft time constraint clause and the execution time estimate; and
providing a second select statement having at least one additional clause to limit selection of rows from a member of the subset of tables by the selected amount according to the selected method, the second select statement being based on the first select statement.

### Claim 30 (depends on 29)

The computer-readable medium of claim 29, where the first select statement includes a clause that specifies the method by which row selection is to be limited.

### Claim 31 (depends on 29)

The computer-readable medium of claim 29, the method including:
selecting an initial number of rows to which row selection will be limited based on a comparison of the initial estimate and the soft time constraint; and
iteratively selecting and analyzing a subsequent number of rows to which row selection will be limited until a time estimate falls within a threshold amount of the soft time constraint, the subsequent number of rows being based on a previous number of rows, a time estimate associated with a previous number of rows, and the soft time constraint.

### Claim 32 (depends on 29)

The computer-readable medium of claim 29, the method including:
selecting an initial sample percentage to which row selection will be limited for a member of the subset of tables based on a comparison of the initial estimate and the soft time constraint; and
iteratively selecting and analyzing a subsequent sample percentage to which row selection will be limited for a member of the subset of tables until a time estimate falls within a threshold amount of the soft time constraint, the subsequent sample percentage being based on a previous sample percentage, a time estimate associated with a previous sample percentage, and the soft time constraint.

### Claim 33

A system, comprising:
means for computing a predicted execution time for a query having a soft time constraint; and
means for rewriting the query based, at least in part, on the predicted execution time and the soft time constraint, where the rewriting includes replacing the soft time constraint with a result set limitation clause.
