Home | Previous Page | Next Page   Dimensional Databases > Implementing a Dimensional Database (XPS) > Using GK Indexes in a Data-Warehousing Environment >

Defining a GK Index on an Expression

You can create a GK index that allows you to store the result of an expression as a key in an index. The following statement creates the cost_idx index, which can improve performance for queries against the sales table that include the cost of the products sold:

CREATE GK INDEX cost_idx ON sales 
   (SELECT units_sold * cost FROM sales);

The database server can use the cost_idx index for the following type of query that returns the names of customers who have spent more than $10,000.00 on products:

SELECT customer_name 
FROM sales, customer
WHERE sales.customer_code = customer.customer_code 
   AND units_sold * cost > 10000.00;
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]