What is the problem with this query?
HelloI need some advice on how to change the following query (with perhaps some analytical function) to speed it up. Currently, it takes 6 + minutes. This query is executed in response to a request from the front-end application and 6 + min is certainly unacceptable.
I am trying to provide as much information I can think, but if more information is needed, please let me know.
I have a table called "wave_result". It contains millions of rows. PK is Wave_Id, Version_nbr, node_nbr and prod_nbr. For each 'wave_id + node_NBR + prod_nbr' there are several versions (version_nbr). In the following query, I try to extract a line with MAX version_nbr for combination of ' wave_id + node_NBR + prod_nbr.
H3. Request:
SELECT ip1.fnln_cat,
ip1.sub_cat,
ip1.bus_cat,
NVL (SUM (ip1.lsu), 0) val
FROM ideal_prod ip1, ideal_store s, wave_result wr
WHERE wr.wave_id = 51
AND wr.prod_nbr = ip1.prod_nbr
AND wr.wave_id = ip1.wave_id
AND wr.version_nbr =
(SELECT MAX (wr1.version_nbr)
FROM wave_result wr1
WHERE wr1.wave_id = wr.wave_id
AND wr1.node_nbr = wr.node_nbr
AND wr1.prod_nbr = wr.prod_nbr)
AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
AND s.wave_id = wr.wave_id
AND s.node_nbr = wr.node_nbr
GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat
H3. Rank of charges:========
"wave_result" is the largest table with millions of rows.
Table Total Rows Rows for wave_id = 51
Ideal_prod 188K 38K
Ideal_store 3K 574
Wave_result 90M 19M
H3. Statsare updated almost daily by the DBA (not sure if that's a good or bad).
H3. Explain the Plan:
=========
SELECT STATEMENT ALL_ROWS Cost: 330,737 Bytes: 401,787 Cardinality: 14,881
12 HASH GROUP BY Cost: 330,737 Bytes: 401,787 Cardinality: 14,881
11 VIEW VIEW SYS.VM_NWVW_2 Cost: 330,737 Bytes: 401,787 Cardinality: 14,881
10 FILTER
9 HASH GROUP BY Cost: 330,737 Bytes: 2,425,603 Cardinality: 14,881
8 HASH JOIN Cost: 327,183 Bytes: 41,233,784 Cardinality: 252,968
1 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKIDEAL_STORE Cost: 4 Bytes: 13,202 Cardinality: 574
7 HASH JOIN Cost: 327,178 Bytes: 35,415,520 Cardinality: 252,968
5 HASH JOIN Cost: 198,619 Bytes: 18,764,328 Cardinality: 183,964
3 TABLE ACCESS BY INDEX ROWID TABLE APAPOPR.IDEAL_PROD Cost: 939 Bytes: 2,272,380 Cardinality: 37,873
4 TABLE ACCESS FULL TABLE APAPOPR.WAVE_RESULT Cost: 197,063 Bytes: 7,974,414 Cardinality: 189,867
6 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKWAVE_RESULT Cost: 82,467 Bytes: 721,495,854 Cardinality: 18,986,733
H3. Sample data:===========
For wave_id = 51
there are 28466854 rows in "wave_result" table
For wave_id = 51 and node_nbr = '0201' and prod_nbr = '0226960'
there are 3 rows in "wave_result" table
H3. Version of database information are below to:=========================
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
Thank you very much!!Concerning
For wave_id = 51
there are 28466854 rows in "wave_result" table
For wave_id = 51 and node_nbr = '0201' and prod_nbr = '0226960'
there are 3 rows in "wave_result" table
As you mentioned that this particular request is called by a front screen, how different search criteria you get it to show on the front end?
Assuming that if the user is searching just of wave_id = 51 which lines returns to 28466854, it is certainly not a good approach to go look up many records to put end Front end is very light and can not hold many records and will be finally the web server will throw off out of memory exception. Always a limit on the number of records that you retrieve from the database and display it on the front plane.
OR
The second case where the user makes a search by wave_id, node_nbr and prod_nbr, even if she returns to 3 lines, behind the scens, he still made a full scan on the wave_result table. If we go with analytical function, we can reduce a sweep of extra table on the wave_result table. Also the table has millions of lines and the max (version_nbr) seems to be a frequently used on this table sub query. While inserting a record into the table wave_result, you must probably have a calculated value that will tell you its value max and you will choose just the rank of this value, instead of at each time max(). something like below...
SELECT ip1.fnln_cat,
ip1.sub_cat,
ip1.bus_cat,
NVL (SUM (ip1.lsu), 0) val
FROM ideal_prod ip1, ideal_store s, wave_result wr
WHERE ipl.wave_id = 51
AND wr.prod_nbr = ip1.prod_nbr
AND wr.wave_id = ip1.wave_id
AND wr.wave_id = s.wave_id
AND wr.node_nbr = s.node_nbr
AND wr.precomputed_max_value = 'MAX'
AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat;
Tags: Database
Similar Questions
-
What is the problem with this query in the source
A blank page is region 2. Region1: enter rec_no (-rec_no is varchar2) region2:hide and show that displays one record based on rec_ no region1 entered.
The problem is that I get the following error
ORA-06550: line 1, column 7: PLS-00428: an INTO clause in this SELECT statement
Here's my simple query in a process of pl/sql
Start
Select rec_no, rec_name from mytable where rec_no = upper(:P16_rec_no);
end;
Why? The same query works under the sql command.
what I'm trying to accompolish here, it is because he has given huge if I want to display hide also multiples, regions and allow users to update each region as a result. Help, please. It kills me that I just can't understand what is causing the problem to the query. Thank you.Hello
The list is set to the field EMPLOYEE_ID itself? What is the primary key of the table? In my example, DEPTNO is the primary key and I used the element generated by the wizard page to display the list. The parameters of the Source of the item itself or the column DEPTNO and database so that the process "process line...". "to identify the updated row.
Andy
-
What is the problem with this query? My head is numb!
Can someone tell me why this request;
< cfquery datasource = "manna_premier" name = "qGetstats" >
SELECT the user name,
UserFirstName,
UserLastName,
LastLogin,
TotalLogins,
UserZone,
TM_Name
USERS
WHERE UserID = ' #. TM_log UserID # '.
< / cfquery >generates this error message;
Run database query error.
[Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Too few parameters. 1 expected. The error occurred in D:\Inetpub\mannapremier\TM_log_report2.cfm: line 28 26 : TM_Name 27 : FROM Users 28 : WHERE UserID = "#TM_log.UserID#" 29 : </cfquery> 30 :
SQLSTATE 07002 SQL SELECT the user ID, UserFirstName UserLastName, LastLogin, TotalLogins, UserZone, TM_Name FROM USERS WHERE UserID = '10120. VENDORERRORCODE -3010 DATASOURCE manna_premier I see that my variable WHERE comes through but the domain name is not working. I'm sure that the answer is obvious, but it drives me crazy!
Help, please!
I tried and got this result;
No, you now use different data. Now, the user ID is empty, while she was 10120 first.
The only problem seems to be double quotes. To check this, test with
WHERE UserID = 10120
I'm assuming that the userID field to be an integer. If it is text, then use single quotes (not!), as in
WHERE UserID = '#TM_log.UserID#'
-
What is the problem with this query? exception does not work.
DECLARE
v_employee_id EMPLOYEES. EMPLOYEE_ID % TYPE;
v_last_name EMPLOYEES. LAST_NAME % TYPE;
v_salary EMPLOYEES. % SALARY TYPE.
e_invalid_emp EXCEPTION;
BEGIN
SELECT last_name, salary v_employee_id, v_last_name, v_salary, employe_id
EMPLOYEES where employee_id = & employee_id;
IF SQL % NOTFOUND THEN
RAISE e_invalid_emp;
END IF;
DBMS_OUTPUT. Put_line(v_employee_id||) e '|| v_last_name | » '|| v_salary);
EXCEPTION
WHEN e_invalid_emp THEN
DBMS_OUTPUT. Put_line ("' employee not found...");
END;
/
-
What is the problem with this WHERE statement?
What is the problem with this WHERE statement?
< cfquery datasource = "manna_premier" name = "kit_report" >
SELECT SaleDate,
TerritoryManager,
Distributor,
DealerID,
Variable,
US_Dealers.ID,
DealerName,
DealerAddress,
DealerCity,
DealerState,
DealerZIPCode
Orders, US_Dealers
WHERE US_Dealers.ID EQ DealerID AND SaleDate BETWEEN #CreateODBCDate (FORM. Implementation) # AND #CreateODBCDate (FORM. End) #.
ORDER BY SaleDate
< / cfquery >It's driving me crazy!
Syntax error (missing operator) in query expression ' US_Dealers.ID EQ DealerID
You accidentally use the CF equals operator: "EQ".
Instead of MS Access: «=»
[Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver]...
in a query expression. AND SaleDate BETWEEN #10/1/2009 #-October 18, 2009 #'.
I don't see how CreateODBCDate() would produce these values. But maybe it's just a quirk of the error message?
-
How I download 80070103 windows update is update safe what is the problem with this update
Just got the update installation today to download update 80070103 time ever I go to download the update fail what is the problem with this update & how do I get updated.
Hello
Thanks for posting in the Microsoft Community.
If I understand correctly that you have problems with Windows Update.
Please answer these questions:
1. What is the update's KB number?
2 have you made any changes to the computer before the show?
Let us try the following methods:
Method 1: Run the following fix - it:
The problem with Microsoft Windows Update is not working:
http://support.Microsoft.com/mats/windows_update/
Method 2: See the following article:
Windows Update 80070103 error code:
http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-Update-error-80070103
Hope the helps of information. We know if you need help. We will be happy to help you.
-
What is the problem with this URL
Can someone tell me what is the problem with this url
It gives me a value for P25_PG, that is to say 3 but always sets P25_JOBID to 0owa_util.redirect_url(apex_util.prepare_url('f?p='||:APP_ID||':25:'||:APP_SESSION||'::'||:DEBUG||':25,28'||':P25_JOBID,P25_PG:&P3_JOBID.,3, null,||:APP_SESSION'));
GusHello Gus,
It looks like point P3_JOBID has no value for the rendering of the page.
If the value is set subsequently, you can try the following changeowa_util.redirect_url(apex_util.prepare_url('f?p='||:APP_ID||':25:'||:APP_SESSION||'::'||:DEBUG||':25,28'||':P25_JOBID,P25_PG:'||:P3_JOBID||',3, null,||:APP_SESSION'));
But the part at the end
||',3, null,||:APP_SESSION'
Wil do nothing because you give only 2 items in the list separated by commas of the page elements you want to submit. Everything after the second comma in the comma separated value list is of no use for the url of the apex.
As additional info, the URL of the Apex is built like this:
>
1 - application ID or alias
2 - page ID or Alias
3 - session & SESSION. : APP_SESSION
4. application (for example, PRINT_REPORT = REPORT_1) & ASK. : REQUEST
5 - debug (YES or NO) & DEBUG. : DEBUG
6 - cache frameworkAPP - clear the cache for the entire application
SESSION - clear the current user session cache
PR - Reset pagination
x - clear the page cache x
-empty the cache for the element y7 - separated by a comma list of items on the page
8 - the list of values separated by commas
9 - mode printer friendly (YES or blank)f? p = & APP_ID.: 1010: & APP_SESSION. : & DEBUG. : RP, 1010:P1010_ITEM1, P1010_ITEM2, P1010_ITEM3:A, B, C
>Kind regards
Kees Vlek
-----
Company: http://www.orcado.nl
Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
Twitter: http://www.twitter.com/skier66
If the answer to question please change replied and mark the appropriate post as correct / helpful. -
What is the problem with this Forum? Why Adobe taking so long to reply to messages?
What is the problem with this Forum? Why Adobe taking so long to reply to messages?
It is in fact 'specific' Forum of Photoshop.
I usually come back another Adobe forum responses quickly.Chime.
Hi people,
For what it's worth, there are several of us who try, in addition to our regular work, to keep an eye on two other forums. Quite simply, we care about the product and try to make sure that we give our customers the best experience as possible. Plus, what better way to hear about your weak points in order to solve them. But, as Mylenium and Christmas as well stress this, the forums are officially a user experience. If you need help fast or official, it isn't the best place to do it.
Regarding your question of Arab, Rahzah, I answered in two different threads and would be happy to help you with your problem. Please choose a single thread and stick with it. two tabs is a pain.
Thank you
DavidPS - some of us do check the forums on our time, as I did last week at the launch while I was on vacation.
-
Could someone explain to me what is the problem with this refined expression?
Hi, could someone explain to me what is the problem with this refined expression
faultCode:Server.Processing faultString:' unable to invoke CFC - regular expression malformed ' ^ [0-2][0-9][/][0-1][0-2][/][1-2][0-9]{3}+$ '.»»
Thank you
I think that the + should not be there. Do you have a match?
-
What is the problem with this pl/sql code?
What is the problem with this statement of the cursor? I am getting PLS-00341 error for her:
How to solve this problem?CURSOR cur_rsource(p_sql_stmt IN VARCHAR2) IS SELECT plan_table_output FROM v$sql s, table(dbms_xplan.display_CURSOR(s.sql_id, s.child_number)) t WHERE sql_text LIKE '''%'||p_sql_stmt||'%''';
Thank you
Published by: PhoenixBai on December 14, 2009 14:05I don't have time right now to study exhaustively, but for me his vomit ORA-00942 table or view does not exist on this line:
SELECT sql_id, child_number into tmp_sql_id, tmp_child_number from v$sql where sql_text like sql_statement||'%' and sql_text not like '%v$sql%';
I am able to select from v$ sql in normal SQL as user I am compiling as, so don't know why it's complaing.
Anyone know if there are certain restrictions on access to the views v$ through PL/SQL?
EDIT: http://www.dbasupport.com/forums/showthread.php?t=22299
Access to the views of $ v seems to be through a role - try giving explicit access to it.
As SYS, you must grant select permissions on V_$ SQL (V$ SQL is synonymous with V_$ SQL) to your owner of the procedure. Just tested on my system and it allows him to compile.
Published by: Cyn on December 14, 2009 10:30
-
What is the problem with this WMF?
Hello
The next WMF is extracted from a word document:
When placed in another Word file or when it is placed in an Open Office Writer document WMF seems fine, but when placed in a product Adobe (Illustrator or InDesign), the letters 'x' and 'f', and 'd' and 'x' stack up to each other.
What is the problem and how to fix it?
Thank you
She helps all select and set auto kerning. Here is what happened to me
Don't notice any specified kerning. Now
With Auto kerning value
-
What is the problem with this dynamic query? help
with the following code, I get the correct answer.
I just want to know maxempno current (and care for the 3rd, 4th tank only)
declare
Temp varchar2 (2);
Start
Select substr (A1.empno, 3, 2) in the emp A1 temp where A1.empno = (select (max (A2.empno) of emp A2) and rownum = 1;)
HTP.p ('temp' is |) Temp)
end;
Temp is 34
=====================================
Now I need to make a call to the procedure and pass the name of a table and column
P_CHECK_MAX
('emp' = > p_table,)
('empno' = > p_column)
create or replace procedure 'P_CHECK_MAX '.
(p_table in VARCHAR2,
p_column in varchar2)
is
Temp varcahr2 (2);
d_select varchar2 (500);
Start
d_select: ='SELECT substr (A1.'| p_column | 3: 2) IN ' | "temp" | 'FROM ' | p_table | "A1 WHERE A1.' | p_column | "= (SELECT max (A2.' | p_column |')) OF ' | p_table | ("A2) AND rownum = 1';
immediately run d_select;
end;
I'm getting ORA - 00905 missing keywords. Can you help me what is the missing word here? I am stomped for hours on it.
Published by: wanwan63 on September 29, 2009 06:23
Sorry I reverse the setting in the call. must be p_table = > 'emp', p_column = > 'empno '.P_CHECK_MAX
("emp"-online p_table,
'empno'-online p_column)It must be
p_check_max(p_table=>'emp', p_column=> 'empno)
d_select: ='SELECT substr (A1.'| p_column | 3: 2) IN ' | "temp" | 'FROM ' | p_table | "A1 WHERE A1.' | p_column | "= (SELECT max (A2.' | p_column |')) OF ' | p_table | ("A2) AND rownum = 1';
immediately run d_select;IN is not part of the SQL syntax. Its syntax PL. If you can not use dynamic SQL. It should be like this
d_select:='SELECT substr(A1.'||p_column|| ',3,2) FROM ' || p_table || ' A1 WHERE A1.' ||p_column ||'= (SELECT max(A2.' ||p_column||') FROM ' || p_table||' A2) AND rownum=1'; execute immediate d_select into temp;
-
Can someone tell me what is the problem with this LOV query please?
This query works very well...
Select filter_name display_value, FILTER_ID return_value
from OTMGUI_FILTER where username = 'ADAM '.
But this one...
Select filter_name display_value, FILTER_ID return_value
from OTMGUI_FILTER where username = apex_application.g_user
Gives the following error.
1 error has occurred
* LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online.
Thank you very much
-Adam vonNiedaAdam:
Define the LOV query as follows
declare l_val varchar2(100) := nvl(apex_application.g_user,'ADAM'); begin return 'select enAME display_value, empno return_value from emp where deptno = '''|| l_val || '''' end;
CITY
-
What is the problem with this PDF?
When I close a certain document PDF Adobe Reader (11.0.2) asks: ' do you want to save changes to... before closing?
Apparently, something is wrong with this document, but what?
The document is displayed correctly.
How can I find out what's wrong with the document?
The document can be found here.
Horn
Thanks for your help guys. I found the problem. Some of the shifts in the xref table were incorrect.
Apparently, Adobe Reader corrects the xref table. When you close the player he manages this fix as a change in the document, thus showing the dialog box "do you want to save.
-
What is the problem with this page and IE?
Gents,
I have this page, exported from Excel to a HTML file, added some jQuery and Spry ToolTips and published it.
It works very well with Firefox and Chrome, but IE trips on it. It simply display a blank page.
Here is the link to the home page: Référence PPBM5
With FF or Chrome test results page appears without a problem with IE, it's just a blank page. It's the page that causes these problems: http://ppbm5.com/Benchmark5.html
Who am I to spoil that IE does not work? Any suggestion is welcome.
Ready for the same problem of crazy...
You have
Benchmark results When I changed it to
Benchmark results It worked.
Gary
Maybe you are looking for
-
Touchpad does not work on Satellite L30 - X 10
Hi to you all.I have the following problem: scrolling on the touchpad does not work on my laptop. If someone can tell me how to solve this problem I would kindly.
-
Update Windows automatically restarts the computer. I would like to disable this feature. I'm running a machine business with complex projects requiring a configuration long and delicate. The details below:Type of operating system: Windows 7 Ultimate
-
Windows Firewall does not, what to do
I install windows xp pro - and the firewall does not open. What can I do?
-
Removing any audiobook at the same time or in part at the same time?
First of all, please allow me to apologize if the answer to my question is somewhere... I looked and looked. Secondly, let me say that I LOVE this little Sansa Fuze 2 GB. I listen to a lot of audiobooks and tried to remove an audiobook while pulling
-
Windows Update that affect my Disortplay Driver and Windows starts?
I recently had this problem where I wouldplaying starcraft or just browsing the netand my screen freeze and tell memy display driver has stopped responding and allfarm down and when it starts, the screen splitsin half with a white line. and then fina