# US 2015/0149402 A1 · Efficient query processing using histograms in a columnar database

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

- Number: US 2015/0149402 A1
- Document ID: US20150149402A1
- Status: Published application
- Kind: A1
- Application number: 14/611,939
- Filed: 2015-02-02
- Published: 2015-05-28
- Earliest claimed: 2013-01-15
- Assignees: Amazon Technologies, Inc.
- Applicants: Amazon Technologies, Inc.
- Inventors: ANURAG WINDLASS GUPTA
- Web page: https://patentgrep.com/patent/US20150149402A1

## CPC

- G06F 16/254: {Extract, transform and load [ETL] procedures, e.g. ETL data flows in data warehouses}
- G06F 16/221: {Column-oriented storage; Management thereof}
- G06F 16/2237: {Vectors, bitmaps or matrices}
- G06F 16/245: Query processing
- G06F 16/24554: {Unary operations; Data partitioning operations}
- G06F 16/278: {Data partitioning, e.g. horizontal or vertical partitioning}
- G06F 16/283: {Multi-dimensional databases or data warehouses, e.g. MOLAP or ROLAP}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A probabilistic data structure is generated for efficient query processing using a histogram for unsorted data in a column of a columnar database. A bucket range size is determined for multiples buckets of a histogram of a column in a columnar database table. In at least some embodiments, the histogram may be a height-balanced histogram. A probabilistic data structure is generated to indicate for which particular buckets in the histogram there is a data value stored in the data block. When an indication of a query directed to the column for select data is received, the probabilistic data structure for each of the data blocks storing data for the column may be examined to determine particular ones of the data blocks which do not need to be read in order to service the query for the select data.

## Claims

### Claim 1

A distributed data warehouse system, comprising:
a plurality of nodes;
wherein at least some nodes of the plurality of nodes each comprise:
storage for a columnar database table, wherein said storage comprises a plurality of data blocks;
a query execution module;
wherein at least one node of the plurality of nodes comprises a height-balanced histogram generator, configured to:
determine a plurality of bucket range sizes for a height-balanced histogram representing a distribution of data among a plurality of buckets in a column of the columnar database table, wherein each bucket of the plurality of buckets represents an existence of one or more data values of the data in the column within a range of values;
generate a probabilistic data structure for each data block of one or more data blocks storing data for the column, wherein the probabilistic data structure indicates for which buckets of the plurality of buckets there is a data value in the bucket range size stored in the data block;
wherein the query execution module is configured to:
receive an indication of a query directed to the column of the columnar database table for select data;
in response to receiving the indication of the query:
examine the probabilistic data structure for each of the one or more data blocks storing data for the column to determine particular ones of the one or more data blocks which do not need to be read in order to service the query for the select data; and
read the one or more data blocks storing data for the column excepting the particular ones of the one or more data blocks which do not need to be read.

### Claim 2 (depends on 1)

The system of claim 1, wherein, to determine the plurality of bucket range sizes for the plurality of buckets for the height-balanced histogram representing the column of the columnar database table, the height-balanced histogram generator is configured to:
obtain the data of the column;
generate the plurality of buckets; and
set a bucket range size of the plurality of bucket range sizes for each bucket for the height-balanced histogram such that the data of the column is evenly distributed among the buckets.

### Claim 3 (depends on 1)

The system of claim 1, wherein the probabilistic data structure is a bitmap comprising a plurality of bits, wherein each bit of the bitmap represents each bucket of the plurality of buckets for the height-balanced histogram, and for every data value included in the bucket range size stored in the data block the bit of the bitmap corresponding to the bucket is set.

### Claim 4 (depends on 1)

The system of claim 1, wherein the height-balanced histogram generator is further configured to store the probabilistic data structure of each of the one or more data blocks in a respective entry in a block metadata structure that stores information about the one or more data blocks.

### Claim 5 (depends on 1)

The system of claim 1, wherein the at least one node is a leader node of a distributed data warehouse cluster, and wherein the at least one of the at least some nodes is a compute node of the distributed data warehouse cluster.

### Claim 6

A method, comprising:
performing, by one or more computing devices:
determining a bucket range size for each of a plurality of buckets for a histogram of a column of a columnar database table, wherein the histogram represents a distribution of data in the column among the plurality of buckets, wherein each bucket of the plurality of buckets represents an existence of one or more data values of the data in the column within a range of values according to the determined bucket range size;
generating a probabilistic data structure for each of one or more data blocks storing data for the column of the columnar database table, wherein the probabilistic data structure indicates for which particular buckets of the plurality of buckets in the there is a data value stored in the data block;
receiving an indication of a query directed to the column for select data; and
in response to receiving the indication of the query, examining the probabilistic data structure for each of the one or more data blocks storing data for the column to determine particular ones of the one or more data blocks which do not need to be read in order to service the query for the select data.

### Claim 7 (depends on 6)

The method of claim 6, wherein said determining a bucket range size for each of a plurality of buckets for the histogram of the column of the columnar database table comprises:
obtaining the data of the column;
generating the plurality of buckets; and
setting a bucket range size of the plurality of bucket range sizes for each bucket such that the data of the column is evenly distributed among the buckets.

### Claim 8 (depends on 6)

The method of claim 6, wherein said generating the probabilistic data structure for each of the one or more data blocks storing data for the column of the columnar database table comprises:
generating a bitmap for the data block comprising a plurality of bits, wherein each bit represents a different bucket of the plurality of buckets for the histogram; and
setting the respective bit in the bitmap for each of the particular buckets for which there is the data value stored in the data block.

### Claim 9 (depends on 8)

The method of claim 8, further comprising storing the probabilistic data structure of each of the one or more data blocks in a respective entry in a block metadata structure that stores information about the one or more data blocks.

### Claim 10 (depends on 9)

The method of claim 9, wherein said examining the probabilistic data structure for each of the one or more data blocks storing data for the column to determine the particular ones of the one or more data blocks which do not need to be read in order to service the query for the select data comprises:
determining one or more bits representing the one or more buckets within the range of values including the select data; and
examining the one or more bits in each bitmap stored in the block metadata structure for the one or more data blocks to identify those data blocks without one of the one or more bits set as the particular ones which do not need to be read in order to service the query for the select data.

### Claim 11 (depends on 6)

The method of claim 6, wherein the histogram of the column of the columnar database table is a height-balanced histogram.

### Claim 12 (depends on 11)

The method of claim 11, further comprising:
detecting a rebalancing event for the distribution of data in the column among the plurality of buckets;
in response to detecting the rebalancing event:
modifying the bucket range size for each of the plurality of buckets for the height-balanced histogram of the column; and
updating each probabilistic data structure for each of the one or more data blocks according to the modified bucket range size of the plurality of buckets.

### Claim 13 (depends on 12)

The method of claim 12, wherein said detecting the rebalancing event for the distribution of data in the column among the plurality of buckets comprises determining that an amount of additional data for the column stored in one or more new data blocks exceeds a rebalancing threshold.

### Claim 14 (depends on 12)

The method of claim 12, wherein said detecting the rebalancing event for the distribution of data in the column among the plurality of buckets comprises analyzing a distribution of an additional amount of data for the column to determine that a change between the distribution of the additional amount of data compared to the distribution of the data in the column exceeds a distribution threshold.

### Claim 15 (depends on 12)

The method of claim 12, further comprising:
subsequent to said updating each probabilistic data structure, receiving an indication that data read from one of the one or more data blocks for servicing the query does not include a data value in the range of data values as indicated by the probabilistic data structure for the one data block; and
updating the probabilistic data structure for the one data block to remove the indication that the data values is included in the range of data values.

### Claim 16 (depends on 6)

The method of claim 6, wherein the data stored in the one or more data blocks for the column is unsorted.

### Claim 17 (depends on 6)

The method of claim 6, wherein the one or more of computing devices are part of a larger collection of computing devices implementing a distributed data warehouse system, wherein the one or more computing devices are one or more compute nodes of a database warehouse cluster, wherein a different computing device of the larger collection of computing devices is a leader node of the database warehouse cluster, and wherein the method further comprises performing, by the leader node, sending one or more queries directed to the column of the columnar database table to the one or more compute nodes.

### Claim 18

A non-transitory, computer-readable storage medium, storing program instructions that when executed by one or more computing devices implement:
determining a bucket range size for each of a plurality of buckets for a histogram of a column of a columnar database table, wherein the histogram represents a distribution of data in the column among the plurality of buckets, wherein each bucket of the plurality of buckets represents an existence of one or more data values of the data in the column within a range of values according to the determined bucket range size;
generating a bitmap for each of one or more data blocks storing data for the column of the columnar database table, wherein each bit in the bitmap represents a different one of the plurality of buckets, and wherein set bits in the bitmap indicate particular buckets of the plurality of buckets in the histogram for which there is a data value stored in the data block;
receiving an indication of a query directed to the column for select data;
in response to receiving the indication of the query:
examining the bitmap for each of the one or more data blocks storing data for the column to determine particular ones of the one or more data blocks which do not need to be read in order to service the query for the select data; and
reading the one or more data blocks storing data for the column excepting the particular ones of the one or more data blocks which do not need to be read.

### Claim 19 (depends on 18)

The non-transitory, computer-readable storage medium of claim 18, wherein the histogram for the column of the columnar database table is a height-balanced histogram.

### Claim 20 (depends on 19)

The non-transitory, computer-readable storage medium of claim 19, wherein the program instructions when further executed by the one or more computing devices implement:
detecting a rebalancing event for the distribution of data in the column among the plurality of buckets;
in response to detecting the rebalancing event:
modifying the bucket range size for each of the plurality of buckets for the height-balanced histogram of the column; and
updating each bitmap for each of the one or more data blocks according to the modified bucket range size of the plurality of buckets.

### Claim at position 21

21-23. (canceled)
