5. A computer-implemented method for use in evaluating queries, the method comprising: receiving a query that includes an expression; determining whether a first part of the expression in the query is equivalent to a first defining expression for a first virtual column of a first table, wherein database metadata defines the first virtual column as a column of said first table that contains, for each row in said first table, a data value computed from the first defining expression; wherein said database metadata includes a name for said first virtual column that is used in queries to reference said first virtual column; determining whether a second part of the expression in the query is equivalent to a second defining expression for a second virtual column of a second table, wherein database metadata defines the second virtual column as a column of said second table that contains, for each row in said second table, a data value computed from the second defining expression; wherein said database metadata includes a name for said second virtual column that is used in queries to reference said second virtual column; in response to determining that the first part of the expression is equivalent to the first defining expression for the first virtual column and that the second part of the expression is equivalent to the second defining expression for the second virtual column, performing the steps of: rewriting the query to generate a rewritten query, wherein the step of rewriting the query comprises: selecting either the first virtual column or the second virtual column; in response to selecting the first virtual column, replacing, in the query, the first part of the expression with the first virtual column; in response to selecting the second virtual column, replacing, in the query, the second part of the expression with the second virtual column; processing the rewritten query; wherein the method is performed by one or more computing devices.
5. A computer-implemented method for use in evaluating queries, the method comprising: receiving a query that includes an expression; determining whether a first part of the expression in the query is equivalent to a first defining expression for a first virtual column of a first table, wherein database metadata defines the first virtual column as a column of said first table that contains, for each row in said first table, a data value computed from the first defining expression; wherein said database metadata includes a name for said first virtual column that is used in queries to reference said first virtual column; determining whether a second part of the expression in the query is equivalent to a second defining expression for a second virtual column of a second table, wherein database metadata defines the second virtual column as a column of said second table that contains, for each row in said second table, a data value computed from the second defining expression; wherein said database metadata includes a name for said second virtual column that is used in queries to reference said second virtual column; in response to determining that the first part of the expression is equivalent to the first defining expression for the first virtual column and that the second part of the expression is equivalent to the second defining expression for the second virtual column, performing the steps of: rewriting the query to generate a rewritten query, wherein the step of rewriting the query comprises: selecting either the first virtual column or the second virtual column; in response to selecting the first virtual column, replacing, in the query, the first part of the expression with the first virtual column; in response to selecting the second virtual column, replacing, in the query, the second part of the expression with the second virtual column; processing the rewritten query; wherein the method is performed by one or more computing devices. 6. The computer-implemented method of claim 5 , wherein the step of selecting either the first virtual column or the second virtual column comprises: determining a first cost for processing a first rewritten query, wherein the first rewritten query is based on the query and is generated by replacing, in the query, the first part of the expression with the first virtual column; determining a second cost for processing a second rewritten query, wherein the second rewritten query is based on the query and is generated by replacing, in the query, the second part of the expression with the second virtual column; determining whether the first cost is higher than the second cost; in response to determining that the first cost is higher than the second cost, selecting the second virtual column; determining whether the second cost is higher than the first cost; in response to determining that the second cost is higher than the first cost, selecting the first virtual column.