Implementation of data access metrics for automated physical database design
The present disclosure involves systems, software, and computer implemented methods for improved design and implementation of data access metrics for automated physical database design. An example method includes identifying a database workload for which index advisor access counters are to be tracked. Each SQL statement in the database workload is executed. For each SQL statement, attribute sets are determined for which a selection predicate filters a result for an SQL statement. An output cardinality of each selection predicate is determined. A logarithmic counter for an attribute set corresponding to the selection predicate is determined based on the output cardinality of the selection predicate. The determined logarithmic counter is incremented. Respective values for logarithmic counters of the determined attributes are provided to an index advisor. The index advisor determines attribute sets for which to propose an index based on the logarithmic counters of the respective attribute sets.
1 . A computer-implemented method comprising:
identifying a database workload for which attribute value access counters are to be tracked, wherein the database workload includes at least one SQL (Structured Query Language) statement;
executing each SQL statement in the database workload, wherein executing a respective SQL statement comprises:
determining attribute values of attributes that are accessed when executing the SQL statement; and
for each attribute for which at least one attribute value is accessed:
maintaining value range counters for the attribute that track counts of attribute value accesses within respective value ranges;
maintaining a stream-summary data structure for the attribute that estimates access frequencies of most frequently accessed attribute values of the attribute; and
determining estimated access frequencies for the attribute values of the attribute using both the value range counters for the attribute and the stream summary data structure for the attribute; and
providing the estimated access frequencies for the attribute values of the attributes to a table partitioning advisor, as the attribute value access counters.
2 . The computer-implemented method of claim 1 , wherein the stream-summary data structure for the attribute includes estimated access frequencies for a predetermined number of most frequently accessed attribute values for the attribute.
3 . The computer-implemented method of claim 1 , wherein maintaining value range counters for the attribute comprises, for a first access of a first attribute value of a first attribute:
determining a first value range for the first attribute that includes the first attribute value, from among a collection of value ranges for the first attribute; and
incrementing a first value range counter for the first value range, in response to the first access of the first attribute value.
4 . The computer-implemented method of claim 3 , wherein each value range in the collection of value ranges for the first attribute has a predefined value range size that indicates how many attribute values of a domain of attribute values for the first attribute are included in each value range.
5 . The computer-implemented method of claim 4 , wherein determining estimated access frequencies for the attribute values of the attribute using the value range counters for the attribute and the stream summary data structure for the attribute comprises determining, for each of the attribute values of the attribute in the stream-summary data structure, whether the estimated access frequency of the attribute value in the stream-summary data structure is a valid estimated access frequency of a most frequently accessed attribute value.
6 . The computer-implemented method of claim 5 , wherein determining whether the estimated access frequency of the attribute value in the stream-summary data structure is a valid estimated access frequency of a most frequently accessed attribute value comprises determining whether the estimated access frequency of the attribute value in the stream-summary data structure is significantly larger than a corresponding value range counter for the attribute value in the stream-summary data structure.
7 . The computer-implemented method of claim 6 , wherein determining whether the estimated access frequency of the attribute value in the stream-summary data structure is significantly larger than corresponding value range counter for the attribute value in the stream-summary data structure comprises determining whether the estimated access frequency of the attribute value in the stream-summary data structure is larger than a product of the corresponding value range counter for the attribute value in the stream-summary data structure and a predetermined tolerance parameter.
8 . The computer-implemented method of claim 5 , wherein determining estimated access frequencies for the attribute values of the attribute using the value range counters for the attribute and the stream summary data structure for the attribute comprises determining whether a first value range includes an attribute value with a valid estimated access frequency of a most frequently accessed attribute value in the stream summary data structure.
9 . The computer-implemented method of claim 8 , further comprising, in response to determining that the first value range does not include an attribute value with a valid estimated access frequency of a most frequently accessed attribute value in the stream summary data structure:
for each attribute value in the first value range:
determining an estimated access frequency of the attribute value in the first value range by dividing a first value range counter of the first value range by the predetermined value range size.
10 . The computer-implemented method of claim 8 , further comprising, in response to determining that the first value range includes a first attribute value with a valid estimated access frequency of a most frequently accessed attribute value in the stream summary data structure:
determining an adjusted value range counter for the first value range by subtracting the valid estimated access frequency of the first attribute value from a value range counter for the first value range;
for each attribute value in the first value range other than the first value:
determining an estimated access frequency of the attribute value in the first value range by dividing the adjusted value range counter by the predetermined value range size; and
determining that an estimated access frequency of the first attribute value is equal to the valid estimated access frequency of the first attribute value.
11 . The computer-implemented method of claim 4 , further comprising:
determining value-range based frequency estimates for the attribute values that are included in the first value range; and
providing the value-range based frequency estimates to the table partitioning advisor as the attribute value access counters for the attribute values that are included in the first value range.
12 . The computer-implemented method of claim 10 , wherein determining value-range based frequency estimates for the attribute values that are included in the first value range comprises dividing the first value range counter by the predetermined value range size.
13 . The computer-implemented method of claim 1 , wherein the table partitioning advisor determines one or more table partitioning criteria based on the estimated access frequencies for the attribute values of the attributes.
14 . A system comprising:
one or more computers; and
a computer-readable medium coupled to the one or more computers having instructions stored thereon which, when executed by the one or more computers, cause the one or more computers to perform operations comprising:
identifying a database workload for which attribute value access counters are to be tracked, wherein the database workload includes at least one SQL (Structured Query Language) statement;
executing each SQL statement in the database workload, wherein executing a respective SQL statement comprises:
determining attribute values of attributes that are accessed when executing the SQL statement; and
for each attribute for which at least one attribute value is accessed:
maintaining value range counters for the attribute that track counts of attribute value accesses within respective value ranges;
maintaining a stream-summary data structure for the attribute that estimates access frequencies of most frequently accessed attribute values of the attribute; and
determining estimated access frequencies for the attribute values of the attribute using both the value range counters for the attribute and the stream summary data structure for the attribute; and
providing the estimated access frequencies for the attribute values of the attributes to a table partitioning advisor, as the attribute value access counters.
15 . The system of claim 14 , wherein the stream-summary data structure for the attribute includes estimated access frequencies for a predetermined number of most frequently accessed attribute values for the attribute.
16 . The system of claim 14 , wherein maintaining value range counters for the attribute comprises, for a first access of a first attribute value of a first attribute:
determining a first value range for the first attribute that includes the first attribute value, from among a collection of value ranges for the first attribute; and
incrementing a first value range counter for the first value range, in response to the first access of the first attribute value.
17 . The system of claim 16 , wherein each value range in the collection of value ranges for the first attribute has a predefined value range size that indicates how many attribute values of a domain of attribute values for the first attribute are included in each value range.
18 . A computer program product encoded on a non-transitory storage medium, the product comprising non-transitory, computer readable instructions for causing one or more processors to perform operations comprising:
identifying a database workload for which attribute value access counters are to be tracked, wherein the database workload includes at least one SQL (Structured Query Language) statement;
executing each SQL statement in the database workload, wherein executing a respective SQL statement comprises:
determining attribute values of attributes that are accessed when executing the SQL statement; and
for each attribute for which at least one attribute value is accessed:
maintaining value range counters for the attribute that track counts of attribute value accesses within respective value ranges;
maintaining a stream-summary data structure for the attribute that estimates access frequencies of most frequently accessed attribute values of the attribute; and
determining estimated access frequencies for the attribute values of the attribute using both the value range counters for the attribute and the stream summary data structure for the attribute; and
providing the estimated access frequencies for the attribute values of the attributes to a table partitioning advisor, as the attribute value access counters.
19 . The computer program product of claim 18 , wherein the stream-summary data structure for the attribute includes estimated access frequencies for a predetermined number of most frequently accessed attribute values for the attribute.
20 . The computer program product of claim 18 , wherein maintaining value range counters for the attribute comprises, for a first access of a first attribute value of a first attribute:
determining a first value range for the first attribute that includes the first attribute value, from among a collection of value ranges for the first attribute; and
incrementing a first value range counter for the first value range, in response to the first access of the first attribute value.