dbTalk Databases Forums  

Function Query

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Function Query in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
artmerar@gmail.com
 
Posts: n/a

Default Function Query - 10-24-2008 , 10:51 AM







Hi,

I have a complex query which uses a regular expression. Is it
possible to somehow create an index or something to speed up the
queries? We're on 10g. I've read a bit about Oracle Text but not
sure if that is for us....

'SELECT * FROM (
SELECT ticker, comp_name FROM (
SELECT ticker, comp_name, 1 ord, ROW_NUMBER()
OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY ticker)
cnt
FROM master_table
WHERE REGEXP_LIKE (UPPER(ticker), ''^' || p_pattern || ''')
UNION
SELECT ticker, comp_name, 2 ord, ROW_NUMBER()
OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
FROM master_table
WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern || '|
' || p_pattern || ''')
)
ORDER BY ord
)
WHERE rownum <= ' || p_num_recs;

Thank you.

Reply With Quote
  #2  
Old   
artmerar@gmail.com
 
Posts: n/a

Default Re: Function Query - 10-24-2008 , 12:59 PM






On Oct 24, 10:51*am, artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression. *Is it
possible to somehow create an index or something to speed up the
queries? *We're on 10g. *I've read a bit about Oracle Text but not
sure if that is for us....

* * 'SELECT * FROM (
* * * *SELECT ticker, comp_name FROM (
* * * * *SELECT ticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY ticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECT ticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;

Thank you.

Well, to close this, I decided to use Oracle Text and have it working
(just about).


Reply With Quote
  #3  
Old   
artmerar@gmail.com
 
Posts: n/a

Default Re: Function Query - 10-24-2008 , 12:59 PM



On Oct 24, 10:51*am, artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression. *Is it
possible to somehow create an index or something to speed up the
queries? *We're on 10g. *I've read a bit about Oracle Text but not
sure if that is for us....

* * 'SELECT * FROM (
* * * *SELECT ticker, comp_name FROM (
* * * * *SELECT ticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY ticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECT ticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;

Thank you.

Well, to close this, I decided to use Oracle Text and have it working
(just about).


Reply With Quote
  #4  
Old   
artmerar@gmail.com
 
Posts: n/a

Default Re: Function Query - 10-24-2008 , 12:59 PM



On Oct 24, 10:51*am, artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression. *Is it
possible to somehow create an index or something to speed up the
queries? *We're on 10g. *I've read a bit about Oracle Text but not
sure if that is for us....

* * 'SELECT * FROM (
* * * *SELECT ticker, comp_name FROM (
* * * * *SELECT ticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY ticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECT ticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;

Thank you.

Well, to close this, I decided to use Oracle Text and have it working
(just about).


Reply With Quote
  #5  
Old   
artmerar@gmail.com
 
Posts: n/a

Default Re: Function Query - 10-24-2008 , 12:59 PM



On Oct 24, 10:51*am, artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression. *Is it
possible to somehow create an index or something to speed up the
queries? *We're on 10g. *I've read a bit about Oracle Text but not
sure if that is for us....

* * 'SELECT * FROM (
* * * *SELECT ticker, comp_name FROM (
* * * * *SELECT ticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY ticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECT ticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;

Thank you.

Well, to close this, I decided to use Oracle Text and have it working
(just about).


Reply With Quote
  #6  
Old   
Peter Nilsson
 
Posts: n/a

Default Re: Function Query - 10-26-2008 , 08:00 PM



artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression.
*Is it possible to somehow create an index or something
to speed up the queries? *We're on 10g. *I've read a
bit about Oracle Text but not sure if that is for
us....

* * 'SELECT * FROM (
* * * *SELECTticker, comp_name FROM (
* * * * *SELECTticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BYticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECTticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;
Did you try my previous suggestion...?

with
x as
(select distinct
ticker, comp_name,
case
when regexp_like(ticker, '^mot| mot', 'i') then 1
when regexp_like(comp_name, '^mot| mot', 'i') then 2
end x
from master_table)
select ticker, comp_name
from (select x.*, row_number() over (order by x.x) rn
from x x
where x.x is not null)
where rn <= 10;

--
Peter


Reply With Quote
  #7  
Old   
Peter Nilsson
 
Posts: n/a

Default Re: Function Query - 10-26-2008 , 08:00 PM



artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression.
*Is it possible to somehow create an index or something
to speed up the queries? *We're on 10g. *I've read a
bit about Oracle Text but not sure if that is for
us....

* * 'SELECT * FROM (
* * * *SELECTticker, comp_name FROM (
* * * * *SELECTticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BYticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECTticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;
Did you try my previous suggestion...?

with
x as
(select distinct
ticker, comp_name,
case
when regexp_like(ticker, '^mot| mot', 'i') then 1
when regexp_like(comp_name, '^mot| mot', 'i') then 2
end x
from master_table)
select ticker, comp_name
from (select x.*, row_number() over (order by x.x) rn
from x x
where x.x is not null)
where rn <= 10;

--
Peter


Reply With Quote
  #8  
Old   
Peter Nilsson
 
Posts: n/a

Default Re: Function Query - 10-26-2008 , 08:00 PM



artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression.
*Is it possible to somehow create an index or something
to speed up the queries? *We're on 10g. *I've read a
bit about Oracle Text but not sure if that is for
us....

* * 'SELECT * FROM (
* * * *SELECTticker, comp_name FROM (
* * * * *SELECTticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BYticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECTticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;
Did you try my previous suggestion...?

with
x as
(select distinct
ticker, comp_name,
case
when regexp_like(ticker, '^mot| mot', 'i') then 1
when regexp_like(comp_name, '^mot| mot', 'i') then 2
end x
from master_table)
select ticker, comp_name
from (select x.*, row_number() over (order by x.x) rn
from x x
where x.x is not null)
where rn <= 10;

--
Peter


Reply With Quote
  #9  
Old   
Peter Nilsson
 
Posts: n/a

Default Re: Function Query - 10-26-2008 , 08:00 PM



artme... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I have a complex query which uses a regular expression.
*Is it possible to somehow create an index or something
to speed up the queries? *We're on 10g. *I've read a
bit about Oracle Text but not sure if that is for
us....

* * 'SELECT * FROM (
* * * *SELECTticker, comp_name FROM (
* * * * *SELECTticker, comp_name, 1 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BYticker)
cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(ticker), ''^' || *p_pattern|| ''')
* * * * *UNION
* * * * *SELECTticker, comp_name, 2 ord, ROW_NUMBER()
* * * * *OVER (PARTITION BY DECODE(ticker,NULL,1,0) ORDER BY
comp_name) cnt
* * * * *FROM master_table
* * * * *WHERE REGEXP_LIKE (UPPER(comp_name), ''^' || p_pattern|| '|
' || p_pattern || ''')
* * * * *)
* * * *ORDER BY ord
* * * *)
* * WHERE rownum <= ' || p_num_recs;
Did you try my previous suggestion...?

with
x as
(select distinct
ticker, comp_name,
case
when regexp_like(ticker, '^mot| mot', 'i') then 1
when regexp_like(comp_name, '^mot| mot', 'i') then 2
end x
from master_table)
select ticker, comp_name
from (select x.*, row_number() over (order by x.x) rn
from x x
where x.x is not null)
where rn <= 10;

--
Peter


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.