Patent ID: 7379927

Claim:
A method of generating a selectivity estimate of a hierarchy query over a plurality of objects, comprising: receiving the hierarchy query over the plurality of objects, each object of the plurality of objects having an associated type, each type having an identifier, said each type being extensible using an inheritance extension, and said each type is a user defined type (UDT); encoding said each object of the plurality of objects with a type path derived from the identifier, wherein said type path comprises a variable-length encoded value, and said variable-length encoded value corresponds to a hierarchy level of a type of an associated object; storing results of the encoding in a column; creating a histogram of the column by using encoded objects; for said each object, determining if a type path of said each object satisfies the query by using the histogram; generating a selectivity estimate of the hierarchy query of the objects by dividing a number of matching objects by a sum of a number of matching objects and a number of non-matching objects, wherein the matching objects have the type path that satisfies the query; and outputting the selectivity estimate of the hierarchy query to a storage device.