# US 2015/0149438 A1 · METHODS AND SYSTEMS FOR CONSTRUCTING q, THETA-OPTIMAL HISTOGRAM BUCKETS

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

- Number: US 2015/0149438 A1
- Document ID: US20150149438A1
- Status: Published application
- Kind: A1
- Application number: 14/154,549
- Filed: 2014-01-14
- Published: 2015-05-28
- Earliest claimed: 2013-11-26
- Assignees: Sap SE
- Inventors: David E. DeHaan
- Web page: https://patentgrep.com/patent/US20150149438A1

## CPC

- G06F 16/24545: {Selectivity estimation or determination}
- G06F 16/2453: Query optimisation
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method and system to determine a q, θ-optimal histogram comprising a plurality of buckets over a data distribution where for any cardinality estimate made using the histogram the cardinality estimate is constrained to obey an acceptability criteria parameterized by q and θ that bounds a ratio error between the cardinality estimate and a true value of the cardinality, q being a factor by which the estimate deviates, at most, from a true value of the cardinality and θ being a threshold value which the cardinality does not exceed, wherein a maximum number of possible query intervals generated in determining the acceptability of the q, θ-optimal histogram is less than quadratic in the number of values.

## Claims

### Claim 1

A computer-implemented method of constructing q, θ-optimal histogram buckets, the method comprising:
determining a q, θ-optimal histogram comprising a plurality of buckets over a data distribution where for any cardinality estimate made using the histogram the cardinality estimate is constrained to obey an acceptability criteria parameterized by q and θ that bounds a ratio error between the cardinality estimate and a true value of the cardinality, q being a factor by which the estimate deviates, at most, from a true value of the cardinality and θ being a threshold value which the cardinality does not exceed, wherein a maximum number of possible query intervals generated in determining the acceptability of the q, θ-optimal histogram is less than quadratic in the number of values.

### Claim 2 (depends on 1)

The method of claim 1, wherein each of the plurality of buckets is to store at least one of a number of distinct values contained in that bucket and a cumulated frequency of the number of distinct values stored therein.

### Claim 3 (depends on 1)

The method of claim 1, wherein a maximum size query interval needed to conclude a guaranteed acceptability is bound by a predetermined formula.

### Claim 4 (depends on 1)

The method of claim 1, wherein if a bucket in the plurality of buckets contains a q, θ-violation, then that bucket also contains a q, θ′-violation for all θ′ less than θ.

### Claim 5 (depends on 1)

The method of claim 1, wherein for an interval [vl,vr) within the plurality of buckets that is a minimal q,θ-violation, if [vr-1,vr) is q-acceptable, then [vl, vr-1) is a q-violation but not a q,θ-violation.

### Claim 6 (depends on 1)

The method of claim 1, wherein a bucket in the plurality of buckets is constructed by incrementally extending a smaller q,θ-acceptable bucket without need to test the new bucket for q,θ-violations whose intervals are wholly contained within the smaller bucket.

### Claim 7 (depends on 1)

The method of claim 1, further comprising constructing individual bucklets within the plurality of buckets of the q, θ-optimal histogram, including allocating compressed storage for: a cumulative frequency for the plurality of buckets, a cumulative frequency of the individual bucklets, and boundaries of the individual bucklets that are interior to an overall histogram bucket interval of the q, θ-optimal histogram.

### Claim 8 (depends on 1)

The method of claim 1, further comprising:
generating, using the q, θ-optimal histogram, cardinality estimates for at least one query execution plan for executing a query;
using the cardinality estimates to determine an optimal query plan for executing the query; and
producing an output of the optimal query plan.

### Claim 9

A non-transitory medium having program instructions embodied thereon, the medium comprising:
instructions to determine a q, θ-optimal histogram comprising a plurality of buckets over a data distribution where for any cardinality estimate made using the histogram the cardinality estimate is constrained to obey an acceptability criteria parameterized by q and θ that bounds a ratio error between the cardinality estimate and a true value of the cardinality, q being a factor by which the estimate deviates, at most, from a true value of the cardinality and θ being a threshold value which the cardinality does not exceed, wherein a maximum number of possible query intervals generated in determining the acceptability of the q, θ-optimal histogram is less than quadratic in the number of values.

### Claim 10 (depends on 9)

The medium of claim 9, wherein each of the plurality of buckets is to store at least one of a number of distinct values contained in that bucket and a cumulated frequency of the number of distinct values stored therein.

### Claim 11 (depends on 9)

The medium of claim 9, wherein a maximum size query interval needed to conclude a guaranteed acceptability is bound by a predetermined formula.

### Claim 12 (depends on 9)

The medium of claim 9, wherein if a bucket in the plurality of buckets contains a q, θ-violation, then that bucket also contains a q, θ′-violation for all θ′ less than θ.

### Claim 13 (depends on 9)

The medium of claim 9, wherein for an interval [vl,vr) within the plurality of buckets that is a minimal q,θ-violation, if [vr-1,vr) is q-acceptable, then [vl, vr-1) is a q-violation but not a q,θ-violation.

### Claim 14 (depends on 9)

The medium of claim 9, wherein a bucket in the plurality of buckets is constructed by incrementally extending a smaller q,θ-acceptable bucket without need to test the new bucket for q,θ-violations whose intervals are wholly contained within the smaller bucket.

### Claim 15 (depends on 9)

The medium of claim 9, further comprising instructions to construct individual bucklets within the plurality of buckets of the q, θ-optimal histogram, including allocating compressed storage for: a cumulative frequency for the plurality of buckets, a cumulative frequency of the individual bucklets, and boundaries of the individual bucklets that are interior to an overall histogram bucket interval of the q, θ-optimal histogram.

### Claim 16 (depends on 9)

The medium of claim 9, further comprising:
instructions to generate, using the q, θ-optimal histogram, cardinality estimates for at least one query execution plan for executing a query;
instructions to use the cardinality estimates to determine an optimal query plan for executing the query; and
instructions to produce an output of the optimal query plan.

### Claim 17

A system comprising:
a computing device comprising:
a memory storing processor-executable program code; and
a processor to execute the processor-executable program code in order to cause the computing device to:
determine a q, θ-optimal histogram comprising a plurality of buckets over a data distribution where for any cardinality estimate made using the histogram the cardinality estimate is constrained to obey an acceptability criteria parameterized by q and θ that bounds a ratio error between the cardinality estimate and a true value of the cardinality, q being a factor by which the estimate deviates, at most, from a true value of the cardinality and θ being a threshold value which the cardinality does not exceed, wherein a maximum number of possible query intervals generated in determining the acceptability of the q, θ-optimal histogram is less than quadratic in the number of values.

### Claim 18 (depends on 17)

The system of claim 17, wherein each of the plurality of buckets is to store at least one of a number of distinct values contained in that bucket and a cumulated frequency of the number of distinct values stored therein, or, in some cases, only a cumulated frequency of the number of distinct values stored therein.

### Claim 19 (depends on 17)

The system of claim 17, wherein a maximum size query interval needed to conclude a guaranteed acceptability is bound by a predetermined formula.

### Claim 20 (depends on 17)

The system of claim 17, wherein if a bucket in the plurality of buckets contains a q, θ-violation, then that bucket also contains a q, θ′-violation for all θ′ less than θ.

### Claim 21 (depends on 17)

The system of claim 17, wherein for an interval [vl,vr) within the plurality of buckets that is a minimal q,θ-violation, if [vr-1,vr) is q-acceptable, then [vl, vr-1) is a q-violation but not a q,θ-violation.

### Claim 22 (depends on 17)

The system of claim 17, wherein a bucket in the plurality of buckets is constructed by incrementally extending a smaller q,θ-acceptable bucket without need to test the new bucket for q,θ-violations whose intervals are wholly contained within the smaller bucket.

### Claim 23 (depends on 17)

The system of claim 17, wherein the processor further executes the processor-executable program code in order to cause the computing device to construct individual bucklets within the plurality of buckets of the q, θ-optimal histogram, including allocating compressed storage for: a cumulative frequency for the plurality of buckets, a cumulative frequency of the individual bucklets, and boundaries of the individual bucklets that are interior to an overall histogram bucket interval of the q, θ-optimal histogram.

### Claim 24 (depends on 17)

The system of claim 17, wherein the processor further executes the processor-executable program code in order to cause the computing device to:
generate, using the q, θ-optimal histogram, cardinality estimates for at least one query execution plan for executing a query;
use the cardinality estimates to determine an optimal query plan for executing the query; and
produce an output of the optimal query plan.
