A function in a subquery is call too many times.
Dear all,
I'm struggling to understand why a function in a subquery is called too many times.
Let me explain with an example:
create or replace function all_emp (v_deptno in number)
return varchar2
as
v_all_emp varchar2(2000);
begin
dbms_output.put_line ('function called');
for i in (select * from emp where deptno = v_deptno) loop
v_all_emp := v_all_emp || i.ename || '; ';
end loop;
return v_all_emp;
end;
-- running just the subquery, calls the function all_emp only 4 times (once for each row in table dept)
select
d.deptno,
d.dname,
all_emp(d.deptno) f_all_emp
from dept d;
-- running the whole query, using regexp to split the value of f_all_emp into separate fields, causes that function all_emp is called 28 times, thus 6 times for each row!!
select tmp.*,
regexp_substr(f_all_emp,'[^;]*',1,1) emp1,
regexp_substr(f_all_emp,'[^;]*',1,3) emp2,
regexp_substr(f_all_emp,'[^;]*',1,5) emp3,
regexp_substr(f_all_emp,'[^;]*',1,7) emp4,
regexp_substr(f_all_emp,'[^;]*',1,9) emp5,
regexp_substr(f_all_emp,'[^;]*',1,11) emp6
from
(select
d.deptno,
d.dname,
all_emp(d.deptno) f_all_emp
from dept d) tmp
;I don't understand why Oracle is calling my function 28 times in this example, 4 times should be sufficient.
Is there a way to force that the subquery is materialized first?
Little background:
Above function / query is of course a simple example.
Actually I have pretty complex function, embedding in a subquery.
The subquery is already slow (2 min to run), but when I want to split the result of the funciton in multiple (approx 20) fields it's over an hour due to above described behaviour.
Optimizer merges in-line view and query results in:
select d.deptno,
d.dname,
all_emp(d.deptno) f_all_emp
regexp_substr(all_emp(d.deptno),'[^;]*',1,1) emp1,
regexp_substr(all_emp(d.deptno),'[^;]*',1,3) emp2,
regexp_substr(all_emp(d.deptno),'[^;]*',1,5) emp3,
regexp_substr(all_emp(d.deptno),'[^;]*',1,7) emp4,
regexp_substr(all_emp(d.deptno),'[^;]*',1,9) emp5,
regexp_substr(all_emp(d.deptno),'[^;]*',1,11) emp6
from dept d
/That's why function is called 28 times. We can see it from explain plan:
SQL> explain plan for
2 select tmp.*,
3 regexp_substr(f_all_emp,'[^;]*',1,1) emp1,
4 regexp_substr(f_all_emp,'[^;]*',1,3) emp2,
5 regexp_substr(f_all_emp,'[^;]*',1,5) emp3,
6 regexp_substr(f_all_emp,'[^;]*',1,7) emp4,
7 regexp_substr(f_all_emp,'[^;]*',1,9) emp5,
8 regexp_substr(f_all_emp,'[^;]*',1,11) emp6
9 from (
10 select d.deptno,
11 d.dname,
12 all_emp(d.deptno) f_all_emp
13 from dept d
14 ) tmp
15 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 3383998547
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 4 | 52 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DEPT | 4 | 52 | 3 (0)| 00:00:01 |
8 rows selected.
SQL> If we use NO_MERGE hint:
SQL> select /*+ NO_MERGE(tmp) */
2 tmp.*,
3 regexp_substr(f_all_emp,'[^;]*',1,1) emp1,
4 regexp_substr(f_all_emp,'[^;]*',1,3) emp2,
5 regexp_substr(f_all_emp,'[^;]*',1,5) emp3,
6 regexp_substr(f_all_emp,'[^;]*',1,7) emp4,
7 regexp_substr(f_all_emp,'[^;]*',1,9) emp5,
8 regexp_substr(f_all_emp,'[^;]*',1,11) emp6
9 from (
10 select d.deptno,
11 d.dname,
12 all_emp(d.deptno) f_all_emp
13 from dept d
14 ) tmp
15 /
DEPTNO DNAME F_ALL_EMP EMP1 EMP2 EMP3 EMP4 EMP5 EMP6
10 ACCOUNTING CLARK; KIN CLARK KING MILLER
G; MILLER;
20 RESEARCH SMITH; JON SMITH JONES SCOTT ADAMS FORD
ES; SCOTT;
ADAMS; FO
RD;
30 SALES ALLEN; WAR ALLEN WARD MARTIN BLAKE TURNER JAMES
D; MARTIN;
DEPTNO DNAME F_ALL_EMP EMP1 EMP2 EMP3 EMP4 EMP5 EMP6
BLAKE; TU
RNER; JAME
S;
40 OPERATIONS
function called
function called
function called
function called
function called
function called
SQL> explain plan for
2 select /*+ NO_MERGE(tmp) */
3 tmp.*,
4 regexp_substr(f_all_emp,'[^;]*',1,1) emp1,
5 regexp_substr(f_all_emp,'[^;]*',1,3) emp2,
6 regexp_substr(f_all_emp,'[^;]*',1,5) emp3,
7 regexp_substr(f_all_emp,'[^;]*',1,7) emp4,
8 regexp_substr(f_all_emp,'[^;]*',1,9) emp5,
9 regexp_substr(f_all_emp,'[^;]*',1,11) emp6
10 from (
11 select d.deptno,
12 d.dname,
13 all_emp(d.deptno) f_all_emp
14 from dept d
15 ) tmp
16 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 2317111044
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 4 | 8096 | 3 (0)| 00:00:01 |
| 1 | VIEW | | 4 | 8096 | 3 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL| DEPT | 4 | 52 | 3 (0)| 00:00:01 |
9 rows selected.
SQL> Not sure why function is executed 6 and not 4 times. What we actually want is to materialize in-line view:
SQL> with tmp as (
2 select /*+ materialize */
3 d.deptno,
4 d.dname,
5 all_emp(d.deptno) f_all_emp
6 from dept d
7 )
8 select tmp.*,
9 regexp_substr(f_all_emp,'[^;]*',1,1) emp1,
10 regexp_substr(f_all_emp,'[^;]*',1,3) emp2,
11 regexp_substr(f_all_emp,'[^;]*',1,5) emp3,
12 regexp_substr(f_all_emp,'[^;]*',1,7) emp4,
13 regexp_substr(f_all_emp,'[^;]*',1,9) emp5,
14 regexp_substr(f_all_emp,'[^;]*',1,11) emp6
15 from tmp
16 /
DEPTNO DNAME F_ALL_EMP EMP1 EMP2 EMP3 EMP4 EMP5 EMP6
10 ACCOUNTING CLARK; KIN CLARK KING MILLER
G; MILLER;
20 RESEARCH SMITH; JON SMITH JONES SCOTT ADAMS FORD
ES; SCOTT;
ADAMS; FO
RD;
30 SALES ALLEN; WAR ALLEN WARD MARTIN BLAKE TURNER JAMES
D; MARTIN;
DEPTNO DNAME F_ALL_EMP EMP1 EMP2 EMP3 EMP4 EMP5 EMP6
BLAKE; TU
RNER; JAME
S;
40 OPERATIONS
function called
function called
function called
function called
SQL> explain plan for
2 with tmp as (
3 select /*+ materialize */
4 d.deptno,
5 d.dname,
6 all_emp(d.deptno) f_all_emp
7 from dept d
8 )
9 select tmp.*,
10 regexp_substr(f_all_emp,'[^;]*',1,1) emp1,
11 regexp_substr(f_all_emp,'[^;]*',1,3) emp2,
12 regexp_substr(f_all_emp,'[^;]*',1,5) emp3,
13 regexp_substr(f_all_emp,'[^;]*',1,7) emp4,
14 regexp_substr(f_all_emp,'[^;]*',1,9) emp5,
15 regexp_substr(f_all_emp,'[^;]*',1,11) emp6
16 from tmp
17 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 634594723
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 4 | 8096 | 5 (0)| 00:00:01 |
| 1 | TEMP TABLE TRANSFORMATION | | | | | |
| 2 | LOAD AS SELECT | | | | | |
| 3 | TABLE ACCESS FULL | DEPT | 4 | 52 | 3 (0)| 00:00:01 |
| 4 | VIEW | | 4 | 8096 | 2 (0)| 00:00:01 |
| 5 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6603_20255AE | 4 | 52 | 2 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
12 rows selected.
SQL> However, hint MATERIALIZE is an undocumented hint.
SY.
Similar Messages
-
I installed 2.3 upgrade,
installer folder is in harddrive but application will not open or replace 2.0 as it says it "should". When I attempt to it just reinstalls the installer, never the functioning application. I have tried too many times now. Always same response. WOuld love to upgrade ( and purge all the alias 2.3 off hardrive!when I went to the library folder there was no receipts only
com.adobe.Reader whihc included install.log
so I guess that means something is missing?
If above still doesn't resolve problem - go to the folder named
"Receipts" in the Mac OS X Library folder (i.e. the main Library
not you Users Library) and delete the file named Adobe Photoshop
Lightroom 2.pkg
> -
Can I call some in the support line bc I have been double charged too many times
Can I call some in the support line bc I have been double charged too many times :-((((
You might have better luck contacting iTunes Support.
-
HT201436 call gets dropped too many times ,network is alright
call gets dropped too many times ,network is alright
It is also relatively easily to dial 911 during the palm reset process as well. Maybe a confirmation screen would be nice.
-
i have been getting this message " no sim installed " too many times then my phone goes off , its iphone 4S , its really a problem i cant get calls or anything and im not sure how to take the SIM out then insert it again , what to do ??
Use the sim tool that came with your phone or a safety pin and just insert it into the hole at the side of the sim tray and push it in and then pull it out. It is no more difficult than that and then just close it again.
-
my phone number is very problem now!
too many times spam call now.
1hour / 400 time call.
very very problem right now.
can you checking the my phone number.
i'm now is my number blocked.
how to fix that. i don't know!
everything is different number!!!
12/19/14 09:00am to still now........
now is can't blocking.
because too many number!
almost 300 more....Since last Friday the 19th, starting on 9:00 A.M I've been getting spam calls from various different numbers and I've gotten over 500 calls from all different numbers. So I put my phone into a temporarily suspended mode. Is there anything you can do to fix this problem?
-
So everytime I watch a movie or listen to music when I use my earphones. A song keeps playing by itself and Siri activates by itself without me even touching it. So I deactivated Siri. And now it's the voice control that keeps coming on. I don't know if my phone is haunted, or there's something wrong with my earphones/earphone socket/jack (or whatever you call where you put it in the earphones), or is it just because I dropped my phone too many times. And I don't want to reset my phone if that's what I have to do. By the way I have an iPhone 4s
If you are wondering why you are not getting any responses, it is because you have vented a complaint without any details that make any sense or give anyone something to work on.
If you want help, I suggest actually detailing what has happened, with versions of software etc. Anything that would let us assist.
As a start I am guessing that you have not really got the hang of "How it all works". Firstly download the Pages09_UserGuide.pdf from under the Help menu. Read that and view the Video Tutorials in the same place. A good addition would be the iWork 09 Missing manual book and something to help you learn how to use your Mac.
If there are specific tasks you need help with:
http://www.freeforum101.com/iworktipsntrick/index.php?mforum=iworktipsntrick
Is a good resource.
Peter -
Just upgraded and iPhoto said it has to upgrade library but keeps freezing. Have tried it too many times now and I need those photos ASAP HELP!!
Option 1
Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
If that fails:
Option 2
Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
Regards
TD -
I have an iphone3 and tried to log in too many times. Now I am locked out. When I press my home button, I get the emergency call screen and not my home screen.
What do I do?Restore the phone using iTunes.
-
I got locked out of the Password & Security section for trying my questions too many times. I was just trying to buy an app and it completely locked me out. Do I have to call iTunes?
Alternatives for Help Resetting Security Questions and Rescue Mail
1. Apple ID- All about Apple ID security questions.
2. Rescue email address and how to reset Apple ID security questions
3. Apple ID- Contacting Apple for help with Apple ID account security.
4. Fill out and submit this form. Select the topic, Account Security.
5. Call Apple Customer Service: Contacting Apple for support in your
country and ask to speak to Account Security.
How to Manage your Apple ID: Manage My Apple ID -
Tab too many times moving to playback toolbar and restarting video
I am using Captvate 2.0. I use Captivate to create what we call LetMe videos where users can actually move through the screens using their keyboard. When I publish the videos, I have discovered that if I forward to the next screen with a specific key (Tab) and the user Tabs too many times, the mouse moves to the payback menu at the bottom of the screen and this can actually cause the video to begin playing again from the beginning of the video (if Enter is hit at the correct setting) or at least, move the cursor out of the active field so. Many of my LetMes have a lot of Tabs in them. We used to use a template for these videos that did not have the playback bar (it did not have a standard skin) but this template has a restricted window size which our software now exceeds.
Any ideas of how to deactivate this toolbar? My users don't need this toolbar. I have tried turning off the buttons, but the toolbar still remains active even through it is not seen.
I cannot use Captivate the way I am using it now and may have to look for a different product unless I can find a solution.
Thanks for your help.
AlyciaHi there
If you don't need the playback controls, just turn them off.
Click Project > Skin > Playback Control tab and DE-select the option to show the playback controls. While you are there, double check to ensure there isn't a border enabled. Click the Borders tab and ensure the "Show Borders" check box is DE-selected.
Cheers... Rick
Click here for Adobe Authorized Captivate and RoboHelp HTML Training
Click here for the SorcerStone Blog
Click here for RoboHelp and Captivate eBooks -
what do i do if my account was locked for answering the security questions wrong too many times?
Apple ID security issues -
Call Apple Care and ask for the Account Security Team. They can assist you with your issue. -
JSP bug? url.openStream() = server redirected too many times
I tried something the other day that works in Java, so it should work as a JSP scriptlet, but I received an error message that others have posted elsewhere without a compete resolution. Specifically, given a URL, say u, one ought to be able to do u.openStream() and eventually read the remote page. Typically, one might want to try
URL u = new URL("http://someserver.com/path/file.xxx")
BufferedReader bfr = new BufferedReader(new InputStreamReader(u.openStream()))and then read bfr line-by-line. The problem that seems to be fairly common is that the openStream() call throws a ProtocolException claiming "server redirected too many times (20), ."
What I've seen is that this exception occurs whenever the URL is outside the Tomcat server whence the call is being made; in our case, we're running "out-of-the-box" Jakarta Tomcat 4.1.29 on port 8080 of a w2k server. The code works perfectly in native Java and in JSP for a URL of the form "/anotherpage.jsp"
Is this a bug in JSP, or in our version of Tomcat, or is there just some configuration parameter that needs to be changed from its default? As I said, I've seen similar posts (with less detailed analysis) in the Usenet newsgroups, but not one has generated a response that explains and resolves the matter.
Perhaps a JSP guru out there could set the record straight? Thanks.
P.S. I know that the use of scriptlets in JSP is being discouraged, but they are still supported AFAIK.Sure scriptlets are still supported. Most times though you can do things better with a custom tag. Why reinvent the wheel?
Just as a suggestion, you might try the JSTL <c:import> tag.
It basically does just this behind the scenes.
However I don't think that will help you in the end - it will probably hit the same error message.
My guess would be that the problem is not caused by java/JSP as such, but by a firewall, or configuration somewhere.
The following works fine for me (ignoring broken images of course)
<%@ page import="java.net.*, java.io.*" %>
<%
URL u = new URL("http://www.google.com");
BufferedReader bfr = new BufferedReader(new InputStreamReader(u.openStream()));
String line = null;
while ((line = bfr.readLine()) != null){
out.println(line);
%>Hope this helps,
evnafets -
Need help I have forgotten my apple security questions and guessed too many times and won't let me reset. What do I do now???
You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
(114957) -
I have followed the steps provided by apple to restore an iPod touch. It is disabled due to having the wrong password entered too many times. When I get part way through the restore process on my computer it pops up a box saying that it can't restore until I enter the passcode into the iPod. I have tried this same process over 5 times now and keep gutting the same results. It is my kids iPod and he has only had it since September. Someone please help me before I throw the thing through the window and my kid strangles me!!! Thanks!
Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
iOS: Wrong passcode results in red disabled screen
If recovery mode does not work try DFU mode.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
Maybe you are looking for
-
hi... End of page triggers only when the body of the list is full... if in the last page I dont have enough data to display the whole page then the end of page is not displayed... how can i achieve this ie. end of page in the last page regards padma
-
MacPro backed up to Time Machine, added Mac Mini now get "The backup disk image "/Volumes/Data/Jerry Booher's MacBook Pro.sparsebundle" is already in use." error when Mac Pro tries to back up
-
I've got a late 2009 iMac 27". When I start it up, it chimes and makes all the normal sounds. The screen flashes white for 2 seconds, then goes black. The iMac starts up (if I use an external monitor, it works fine) but the screen remains black. Weir
-
How do I install Adobe Shockwave Player on the new Macbook Air 2013
I have just purchased the new Macbook Air 2013 I was trying to install the Adobe Shockwave Flashplayer. Now it dowloads but the problem is that when I go try to play the game it still says I am missing a plug-in. I have been trying to switch it to op
-
Making movie project in iDVD without a theme - still having trouble. help!
I am trying to make a movie in iDVD without a theme. I am following previous instructions but having a problem. I open up iDVD, create a new project. Pick a theme, then select the map view. When the screen opens I drag my movie into the first box whi