• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Function Based Indexes

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

Why is that we should avoid using Oracle functions in the Where clause of a SQL statement? and how does Function Based Indexes help in this scenario?
[ November 04, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jothi,
Oracle user-defined functions in SQL query WHERE clauses are executed for each row of the result set returned by the query, which may degrade performance substantially.
Note that this is not the case for Oracle built-in functions, like NVL, for example.
I don't know for certain, but I assume that a function based index stores the function results in the index and hence avoids repeated execution of the function which would therefore provide better performance.

Good Luck,
Avi.
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jothi Shankar Kumar Sankararaj:
Guys,

Why is that we should avoid using Oracle functions in the Where clause of a SQL statement? and how does Function Based Indexes help in this scenario?

[ November 04, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]



Primarily the issue is with date functions (not all functions) because translation between the function and the storage of the date invalidates the where clause and causes a full table scan.

For example:



The claim_dt column may have an index, but the the trunc and to_char functions will invalidate the index, causing a full-table scan to occur.

One of the things you can do to prevent this performance impact is to create a function-based index.


You could also just fix your where clause:


You could also create a redundant column in the table.

[ November 10, 2008: Message edited by: Paul Campbell ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic