|
|
> | Computers > Databases > |
Functions |
||
|
||||||||
|
||||||||
|
||||||||
|
|
Preview DRM-free music
Get information on your favorite TV Shows at
Clarify the meaning of the acronyms on your web site. Register your own domain name at A to Z Domains. or buy domains at Domain Names For Sale .net
Printer-friendly PDF* format: |
Avoid functions on index columnsApplying a function to a key column will prevent the >DBMS from being able to search the index using the column value. For example, given these two queries to retrieve a particular row:
select * from t where keycol = :hostvar;
The first query can use the index to find the row very quickly. For the second query, the database must retrieve every value of the key column from either the table or the index, in order to apply the function to those values. If possible, move the function to the other side of the expression:
select * from t where keycol = rpad(:hostvar, n);
When to use a function indexSome databases allow creating an index on a function of a column.
Using a function index becomes necessary when there is no inverse
function that allows moving the function to a non-indexed value.
For example, most databases always use case-sensitive comparisons,
and there is no inverse function for a
select ... from schema.tablename where lower(trim(email_address)) = lower(trim(:emailaddr));
To avoid a table or index pagespace scan to convert all of the email_address values to lower case, a function index could be created on that column.
create index schema.indexname
Watch out for implied coersion of key columnsImplied coersion of key columns can result in the same type of
problems that are caused by explicit functions.
For example, when the fixed length
GENDER = 'MALE'
These examples should be avoided because they will cause automatic padding of
the
GENDER = 'UNKNOWN'
Last updated Thursday November 16, 2006 |
You are currently viewing this page in HTML 5 XML* format (* see Clicklets for more infomation). This document is also available in XML* HTML 5 non-XML*XHTML 1 Style Sheet*HTML 5 Style Sheet* XHTML 1* HTML 4* XHTML 2* XHTML Mobile* WML Mobile* and printer-friendly PDF* formats. This is accomplished with Single Source Publishing, a content management system that uses templates in XSLT style sheets provided by XML Styles .com to transform the source content for various content delivery channels. There is also RDF* metadata that describes the content of this document.
Copyright © 2006 How To Guides .com. Alteration of content, including addition of any function such as hypertext links or pop-up advertising, or interference with the hypertext links or other functions of this site is expressly prohibited.
DISCLAIMER: All information, links, forms, applications and other items on this site or obtained from it are provided AS IS, WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.