Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Performance Help

Re: SQL Performance Help

From: sybrandb <sybrandb_at_gmail.com>
Date: 14 Dec 2006 22:16:46 -0800
Message-ID: <1166163406.806409.126450@f1g2000cwa.googlegroups.com>

Brian Kelly wrote:
> I'm working on an auto population program and this program has to
> execute thousands of SQL statements. Each SQL statement really dumbs
> down the comparing field using Oracle's built in functions lower() and
> about 6 replace()'s. These REALLY slow down the execution of each of
> these statements ALOT. A statement, for example might be like this.
>
> UPDATE blah
> SET field1='whatever',field2='whatever'
> WHERE replace(replace(replace(lower(comparison_field),'-'),'.'),'\')
> LIKE '%keyword%';
>
> However, I've also grouped similar statements together like this
>
> UPDATE blah
> SET field1='whatever',field2='whatever'
> WHERE replace(replace(replace(lower(comparison_field),'-'),'.'),'\')
> LIKE '%keyword1%'
> OR replace(replace(replace(lower(comparison_field),'-'),'.'),'\') LIKE
> '%keyword2%'
> OR replace(replace(replace(lower(comparison_field),'-'),'.'),'\') LIKE
> '%keyword3%'
> OR ...;
>
> The grouped statements take [insert # of LIKE's comparisons here] times
> longer then the first statement due to the fact that it has to
> re-execute these functions for every comparison. Is there any way to
> execute the functions once and then reference that result later in the
> same SQL statement? Any help would be appreciated.

Your problems are NOT being caused by those functions!!!!!!!!!! They are being caused by you
- NOT using BIND VARIABLES, forcing Oracle to parse every statement - using FULL TABLE SCANS all over the place, by virtue of NOT using Function Based Indexes and predicates which CAN actually use an index.

Built-in functions are not time consuming at all, and obviously they need to be, by virtue of your statements, to be applied on every individual record!

-- 
Sybrand Bakker
Senior Oracle DBA
Received on Fri Dec 15 2006 - 00:16:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US