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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Help - Query running slow

RE: Help - Query running slow

From: Alroy Mascrenghe <mark_alroy_at_yahoo.co.uk>
Date: Sat, 6 May 2000 07:52:04 +0100 (BST)
Message-Id: <10488.105126@fatcity.com>


Salu

The way to avoid rtrim is to use LIKE and use % on the variable. ( To use RPAD on the variable you must know the no of spaces...in the table column !!)This will enable the index. If you are using a char column then listen to the advice of Carlos Alvarez !! use a varchar column !!

> SELECT DISTINCT emp_id INTO ret_empid
> > FROM emp_code
> > WHERE MGMT_CD LIKE empid||'%';

As i read your initial question i also find another problem. I think-think you are calling a PL/SQL function from a sql select. That will slow down the query any way. You should call SQL from PL/SQL. But calling PL/SQL from SQL is not a wise idea.......( I agree there are exceptions).

Using LIKE will solve the problem most probably...in case if it doesn't ..
What you can do is instead of calling the function in the initial select write a select like this before that 'initial' select

       cursor blabla is
         SELECT  emp_id , MGMT_CD, MRKT_CD, ACCT_CD
         FROM emp_code
         WHERE ( MGMT_CD LIKE empid||'%' or ACCT_CD 
LIKE empid||'%' OR MRKT_CD LIKE empid||'%' ) .........
      IF MGMT_CD IS NOT NULL THEN..........
               variable_for_initial_select := emp_id;
THEN write the 'initial' SELECT with the variable 'variable_for_initial_select'

Alroy

mark_alroy_at_yahoo.co.uk

Received on Sat May 06 2000 - 01:52:04 CDT

Original text of this message

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