14. The system of claim 13 , wherein the machine-readable program code further includes instructions for receiving match query and determining whether the query is a full string match query type or a sub-string match query type, and includes instructions such that (i) if the match query is determined as being a full string match query type, then finding the appropriate bucket using maximum a posterior probability, and (ii) if the match query is determined as being sub-string match query type then (a) estimating the frequency of the sub-string in each bucket, and (b) computing a weighted sum of bucket selectivity based on said frequency.
13. A system for collecting and storing string match and substring match statistics for a database of documents composed in a language of strings associated with attributes comprising: a machine-readable storage medium; a machine-readable database of said documents including a plurality of data content values, with a corresponding attribute associated with each of said plurality, wherein said values comprise strings and substrings; machine-readable program code, stored on the machine-readable storage medium, the machine-readable program code having instructions to provide a memory limit value, and instructions for constructing a histogram consisting of multiple buckets of partitioned path-value pairs using a data model to construct a value synopsis for each of said buckets, wherein each bucket stores an average selectivity for the path-value pairs belonging to the bucket, wherein the instructions are such that the constructing is such that the value synopsis encodes both a probability that a full string belongs to a given bucket, and an estimate of a frequency of sub-strings in each bucket, and summarization of data model parameters so that entire histogram fits within said memory limit value, and machine readable program code for returning estimated selectivity i) for the full string as the average selectivity of an appropriate bucket and ii) for the sub-string as a weighted sum across all buckets of the average selectivity times the frequency of sub-strings in each bucket.