EP1548612A1

Method and device for providing column statistics for data within a relational database

Abstract

The invention relates to a method, a computer program and a device for providing column statistics for data within a relational database, in particular a DB2 database, for selecting an access path to said data. To aid the DB2 OPTIMIZER in selecting an optimal access path based on actual frequency statistics, the collection of column statistics may be carried out automatically with the steps of collecting database queries to be executed on the database, parse the database queries to create at least one usage matrix comprising at least usage information of certain statements within the database queries, determining from said usage matrix columns within said database for which said columns statistics are useful, and collect said column statistics for said determined columns.

EP1548612A1, drawing sheet 1
Sheet 1 of 6

Term

Term ended

Projected expiry passed 22 December 2023, 2.8 years ago.

  1. Priority and filed
  2. Published
  3. Projected expiry
  4. Today

15 claims: 14 independent, 1 dependent

  1. 1
    Method for providing column statistics for data within a relational database, in particular a DB2 database, in order to select an access path to said data, with the steps of:a) collect database queries to be executed on said database, b) parse said database queries to create at least one usage matrix comprising at least usage information of certain statements within said database queries, c) determine from said usage matrix columns within said database for which said column statistics are useful, and d) collect said column statistics for said determined columns.
  2. 3
    The method of any one of claims 1 to 2, wherein said database queries are parsed to determine compound statements.
  3. 4
    The method of any one of claims 1 to 3, wherein said database queries are parsed to determine compound statements executed on joined tables comprising an AND statement in their WHERE clause.
  4. 5
    The method of any one of claims 1 to 4, wherein said database queries are parsed to determine statements comprising one of the following syntax:columnname?, columnnameliteral, columnnamecolumnname, columnname:host variable.
  5. 6
    The method of any one of claims 1 to 5, wherein said usage matrix is created comprising information about tables, columns, occurrence rates, and/or page reads.
  6. 7
    The method of any one of claims 1 to 6, wherein availability of complete frequency statistics for first index columns is checked prior to step a), and wherein in case of non-availability said complete frequency statistics are determined for respective first index columns.
  7. 8
    The method of any one of claims 1 to 7, wherein in step c) column statistics for columns which are queried by said statements most frequently are determined as useful.
  8. 9
    The method of any one of claims 1 to 8, wherein in step c) column statistics for columns whose queries by said statements consume most processor time are determined as useful.
  9. 10
    The method of any one of claims 8 or 9, wherein a threshold value of 80% is defined for determining the most frequently queried and/or most processor consuming columns.
  10. 11
    The method of any one of claims 1 to 10, wherein said column statistics comprise frequency statistics determining an occurrence frequency of a value within a column.
  11. 12
    The method of any one of claims 1 to 11, wherein said occurrence frequency is analyzed on a per table, SQL, occurrence, and/or processor cost basis to determine which of said column statistics are useful.
  12. 13
    A computer program for providing column statistics for data within a relational database, in particular a DB2 database, for selecting an access path to said data, comprising instructions operable to cause a processor to:a) collect database queries to be executed on said database, b) parse said database queries to create at least one usage matrix comprising at least usage information of certain statements within said database queries, c) determine from said usage matrix columns within said database for which said column statistics are useful, and d) determine said column statistics for said determined columns.
  13. 14
    A computer program product for providing column statistics for data within a relational database, in particular a DB2 database, for selecting an access path to said data, with a computer program stored thereon comprising instructions operable to cause a processor to:a) collect database queries to be executed on said database, b) parse said database queries to create at least one usage matrix comprising at least usage information of certain statements within said database queries, c) determine from said usage matrix columns within said database for which said column statistics are useful, and d) determine said column statistics for said determined columns.
  14. 15
    A device for providing column statistics for data within a relational database, in particular a DB2 database, for selecting an access path to said data, comprising:storage means for storing at least one database, computing means for providing and executing database queries on said database, collection means for collecting database queries to be executed on said database, parsing means for parsing said database queries to create at least one usage matrix comprising at least usage information of certain statements within said database queries, determination means for determining from said usage matrix columns within said database for which said column statistics are useful, and retrieval means for determining said column statistics for said determined columns.