主权项 |
1. A method for optimizing resource usage when accessing a database based on an estimation of a cardinality of a joined table (T) obtained by joining at least a first data column (R) and a second data column (S), wherein R and S each comprise attribute values, and wherein the method comprises:
receiving, by one or more processors, a first density distribution function f(x) describing a frequency of attribute values of the first data column (R); receiving, by one or more processors, a second density distribution function (g(x)) describing a frequency of attribute values of the second data column (S); receiving, by one or more processors, a first information on values in the first data column (R) based on a sample of values of the first data column (R); receiving, by one or more processors, a second information on values in the second data column (S) based on a sample of values of the second data column (S); estimating, by one or more processors, a cardinality of a joined table (T) based on the first and second density distribution functions (f(x), g(x)) and the first and second information on values; receiving, by one or more processors, a request from a client computer for data from a database in a database server; comparing, by one or more processors, an estimated cardinality of the joined table (T) to estimated cardinalities of other joined tables created from the database; in response to determining that the estimated cardinality of the joined table (T) is less than any of the estimated cardinalities of the other joined tables created from the database, minimizing execution time and computer resource usage when responding to the request for data by utilizing, by one or more processors, the joined table (T) before utilizing any of the other joined tables created from the database; and generating and transmitting, by one or more processors, the joined table (T) to a requester of the request for data. |