×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Hi Franco
It looks like (I'm guessing) that the culprit is the udf myfunction
Have you tried creating a work file
Insert into work_file
(select field1 from mytable
where field2 like 'A%')

Then running a separate SQL over work_file
select
myfunction(field1) from work_file where field2 like 'A%'
and see what the times are like
Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Franco Lombardo
Sent: Monday, May 14, 2012 1:03 PM
To: midrange-l@xxxxxxxxxxxx
Subject: User defined SQL function


Hi all,

I have an SQL problem. I have a query like this

select
myfunction(field1) from mytable where field2 like 'A%'

The table mytable
is really big, the selection like 'A%' extracts quickly only a few records, while myFunction is a bit slow A "good" execution plan should extract records and apply myFuntion to the results, but the system applies myFunction to the whole table, and then it does the filter...it takes forever....

I
tried to rewrite my query this way:

with x as (select field1 from mytable
where field2 like 'A%')
select myfunction(field1) from x

but it's
still very slow!

Can you help
me?

Bye

Franco


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.francolombardo.net
Scala,
Java, As400.....
http://twitter.com/f_lombardo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.