TIME KF in the query??
Hi all,
I loaded data from ODS to Cube and have Time CHARs in my Cube. But I don't have any values for my TIME CHARS in the query. Can someone tell me how to fix it?
Thanks
J.
Hi John,
Just check the Update Rules and Transfer Rules whether mapping has been done properly for the Time Chars and also check whether data exists for Time Chars in the underlying ODs from which the data is pulled into Cube.
Thanks,
Vamsi
Similar Messages
-
Sdn
Im getting Time out for one query while excuting in PRD system. That query filter field setting is Only values Infoprovider. But DEV Im able to excute the same query, but in this system that field setting is Only posted values in navigation
advance wishesHi Kirun,
I'm sure, it can be done in dev because the data is not big like in the production.
You need to tune up your info provider (info cube/ods).
I had once the problem like you, i can run in dev, but not in prd.
due I use ODS, so that I tuned it up by creating Index. And after it, it can run well.
If it's Info cube, you can create aggregate / compress it.
Hope it helps you a lot.
Br,
Daniel N. -
Difference between DB time OLAP time frontend time when execute the query
hi all,
can you any one explain the difference between DB time, OLAP time, frontend time when execute the queryEach BEx quey form a SQL query which is called query execution plan.
So,
DB Time is the time taken to read the record from data base by the SQL statement.
OLAP time is the time taken to process the calculations/formula involved.
Frontend Time is the time taken to present the output. For ex: while displaying the data in Bex analyser if your query involves a hierarchy, then the presentation time will be more. It also includes the time user taken to enter the query selection input. -
How to Automate the Query Search Upon Return to the Calling Form?
Greetings Ya’ll Gurus,
Could you please share with me how to make the Query Search executed automatically each time, when database table is updated, upon return to the “Calling Form” (i.e. FormA in this posting) from the “Called Form” (i.e. FormB from here on)?
I have FormA call_form to FormB. FormB may return to FormA. FormA allows users to enter the Query parameters and perform query Search to the database table with a list of search results afterward; whereas FormB allows users to add or delete the same database table records. Both form images are as follows:
FormA:
!http://dot.state.ak.us/nreg/jtomasic/FormA_DWR_SEL.GIF!
FormA call_form to FormB by clicking PB “Daily Work Report” (see circled PB "Daily Work Report" in the above image.)
FormB Image (FormB allows users to add and delete database records):
!http://dot.state.ak.us/nreg/jtomasic/FormB_DWR.GIF!
FormB EXIT_FORM and returns to FormA (see circled PB "DWR Selection" in above image).
Currently, our users must press the PB “Search” on FormA each time to refresh the Query “Search” results after returning to FormA, and they request to have the "Search" done automatically/programmatically upon return to FormA each time when the database table is updated.
If you have programming code on this and are willing to share or if you have any suggestion or thoughts on this, it would be most greatly appreciated.
Thanks a lot & Happy Holidays!Thanks so much Andreas, and yes, your link for calling a form and passing a context is very helpful. I believe, your suggested use of the global variable for the saved database table will work for the automation of the Query Search. I am, however, not sure how to make the code and the trigger to automatically perform Query PB "Search". The code for our current "WHEN-BUTTON-PRESSED" Trigger for the PB-Search of FormA is as following:
DECLARE
alert_button NUMBER;
alert_id ALERT;
MY_WHERE VARCHAR2(2500);
MY_DIST_ID DIST.DIST_ID%TYPE := :BLK_UPDATE.DIST_ID;
MY_ORG_ID DWR.ORG_ID%TYPE := :BLK_UPDATE.ORG_ID;
MY_ACTY_ID DWR.ACTY_ID%TYPE := :BLK_UPDATE.ACTY_ID;
MY_ACTY_WORK_ID DWR.ACTY_WORK_ID%TYPE := :BLK_UPDATE.ACTY_WORK_ID;
MY_CNTY_ID DWR.CNTY_ID%TYPE := :BLK_UPDATE.CNTY_ID;
MY_ASSET_GRP_ID DWR.ASSET_GRP_ID%TYPE := :BLK_UPDATE.ASSET_GRP_ID;
MY_ASSET_ID DWR.ASSET_ID%TYPE := :BLK_UPDATE.ASSET_ID;
MY_RTE DWR.RTE%TYPE := :BLK_UPDATE.RTE;
MY_BEG_MP DWR.BEG_MP%TYPE := :BLK_UPDATE.BEG_MP;
MY_END_MP DWR.END_MP%TYPE := :BLK_UPDATE.END_MP;
MY_FROM_DATE DWR.DWR_DATE%TYPE := :BLK_CONTROL.FROM_DATE;
MY_TO_DATE DWR.DWR_DATE%TYPE := :BLK_CONTROL.TO_DATE;
MY_FLAG_OFFSYS VARCHAR2(11) := :BLK_UPDATE.FLAG_OFFSYS;
MY_FLAG_COMMENTS VARCHAR2(11) := :BLK_UPDATE.FLAG_COMMENTS;
MY_SPECIAL_EVENT_SEQ_NO SPECIAL_EVENT.SPECIAL_EVENT_SEQ_NO%TYPE := :BLK_UPDATE.SPECIAL_EVENT_DESCR;
MY_FLAG_ACCDT VARCHAR2(11) := :BLK_UPDATE.FLAG_ACCDT;
BEGIN
:blk_control.dummy_flag := 1 ;
:BLK_CONTROL.DUMMY_ERR_FLAG := 'N';
VALIDATION_SELECTION; -- Program Unit VALIDATES DWR SELECTION PARAMETERS PRIOR TO
-- PERFORMING THE SEARCH AND POPULATING THE DISPLAY BLOCK
if :blk_control.dummy_flag = 1 then
IF :BLK_CONTROL.DUMMY_ERR_FLAG = 'N' THEN
MY_WHERE := BUILD_WHERE_CLAUSE(MY_DIST_ID,
MY_ORG_ID,
MY_ACTY_ID,
MY_ACTY_WORK_ID,
MY_CNTY_ID,
MY_ASSET_GRP_ID,
MY_ASSET_ID,
MY_RTE,
MY_BEG_MP,
MY_END_MP,
MY_FROM_DATE,
MY_TO_DATE,
MY_FLAG_OFFSYS,
MY_SPECIAL_EVENT_SEQ_NO,
MY_FLAG_ACCDT,
MY_FLAG_COMMENTS);
SET_BLOCK_PROPERTY('BLK_DISPLAY', DEFAULT_WHERE, MY_WHERE);
GO_BLOCK('BLK_DISPLAY');
CLEAR_BLOCK(NO_VALIDATE);
EXECUTE_QUERY(ALL_RECORDS);
IF :BLK_DISPLAY.DWR_SEQ_NO IS NOT NULL THEN
SET_ITEM_ON_OR_OFF('BLK_CONTROL.PB_PRINT', TRUE);
ELSE
SET_ITEM_ON_OR_OFF('BLK_CONTROL.PB_PRINT', FALSE);
alert_id := FIND_ALERT('no_data_query');
IF ID_NULL(alert_id) THEN
error_msg(1000);
ELSE
set_alert_message(alert_id, 1040);
alert_button := SHOW_ALERT(alert_id);
END IF;
END IF;
GO_BLOCK('BLK_UPDATE');
GO_ITEM('BLK_CONTROL.PB_SEARCH');
END IF;
end if;
END;My questions are:
After initializing, set and/or reset the global variable for the saved database table,
do I copy the above code (i.e. the "entire" code in the "WHEN-BUTTON-PRESSED" Trigger for the PB-Search) to the WHEN-NEW-FORM-INSTANCE-trigger, or other trigger(s), of FormA to automate the Query Search whenever there is a successful database commit/save? Or
is there a simple way to activate the code in the "WHEN-BUTTON-PRESSED" Trigger for the PB-Search of FormA? Or
is there a simple way to activate the EXECUTE_QUERY(ALL_RECORDS) command in the WHEN-NEW-FORM-INSTANCE-trigger or other trigger(s) of FormA ?
Thanks and always. -
Tuning the query : Very Urgent
Hi
We have query wich needs tuning.when we are putting REGULAR EXPRESSION query is running fine but whne we put like LIKE stmt it is taking time.Here is the query below.Please help on tuning.
SELECT a.order_number, b.last_update_date,TO_CHAR( b.split_percent,'FM99999.009') SPLIT_PERCENTAGE,
rs.NAME " SALES_PERSON_NAME ", rs.salesrep_number, b.effective_date,
b.creation_date "CREATION_DATE", rt.NAME "TERRITORY_NAME",
rt.segment1 "ERP_CODE", a.booked_date "DATE_BOOKED",
TO_CHAR(ROUND((( (SELECT SUM (ordered_quantity * unit_selling_price)
FROM apps.oe_order_lines_all ol
WHERE ol.header_id = a.header_id)
* b.split_percent
/ 100
) , 2),'FM99999999999999999999.009') order_total ,
(SELECT user_name
FROM fnd_user
WHERE user_id = b.last_updated_by) requested_by,
b.obsolete_date
FROM oe_order_headers_all a,
apps.csm_header_sales_cr_hist b,
jtf_rs_salesreps rs,
ra_territories rt
WHERE 1 = 1
AND a.header_id = b.source_header_id
AND b.territory_id = rt.territory_id
AND b.salesrep_id = rs.salesrep_id
AND b.source_type = 'O'
AND a.order_number IN (
SELECT a.order_number
FROM oe_order_headers_all a,
apps.csm_header_sales_cr_hist b,
jtf_rs_salesreps rs,
ra_territories rt
WHERE 1 = 1
AND a.header_id = b.source_header_id
AND b.territory_id = rt.territory_id
AND b.salesrep_id = rs.salesrep_id
AND b.source_type = 'O'
-- AND b.obsolete_date IS NULL --ommented by andondap as per TD#9648 Changes
AND REGEXP_LIKE ( rs.name , '(svc)|(Muti.*Y)|(Multi.*Y)|(._MY)') Commented by andondap as per TD#9648 Changes
AND b.last_update_date BETWEEN TO_DATE ('2012/11/25', 'YYYY/MM/DD') AND TO_DATE ('2013/03/23', 'YYYY/MM/DD')+ 0.9999
AND REGEXP_LIKE ( rs.name,'(.MY)|(Muti.*Y))|(Multi.*Y)|(._MY) |(mlti)')
AND rs.name LIKE '%SVC%MULTI%' OR rs.name NOT LIKE '%DUMMY%' OR rs.name LIKE 'Svc%Multi%' OR rs.name LIKE 'Svc%MY%'
OR rs.name LIKE 'Service%Multi%' OR rs.name LIKE '%MY_SHARE_TM' OR rs.name LIKE '%MY_SHARE_T')
ORDER BY a.order_number, b.creation_date
Thanks
HibinHmmm, let's see...
1. OP provided formatted code using {noformat}{noformat} tags.... - FAILED
2. OP provided database version in full... - FAILED
3. OP provided table structures and index information... - FAILED
4. OP provided cardinality and selectivity information... - FAILED
5. OP provided explain plans... - FAILED
6. OP provided execution traces... - FAILED
7. OP is a new member and can be excused for above failures... - FAILED
8. OP has asked previous questions and followed forum etiquette by marking them as answered... - FAILED
9. OP has respected volunteers and other questioners by not marking his question as Urgent... - FAILED
10. OP has read the forum FAQ ({message:id=9360002}) for posting his question... - FAILED
11. OP has read the forum FAQ ({message:id=9360003}) for posting a tuning question... - FAILED
It's a good job you're not a computer program, you wouldn't have even compiled.
so, points to note:
This is a forum of volunteers. There's no such thing as an Urgent question here, and it's considered rude to suggest your question is urgent, as that indicates you want immediate attention from the people who are giving up their own time to help, and who have their own jobs to do. It's also rude for the other people who are asking questions, as everyone would like an answer to their problem as soon as possible, so what makes you any more special? An urgent issue is one where a live system is down potentially putting people's lives at risk or causing a company to lose money, or somehow damage their services. Such issues should be logged with Oracle Support, not on the free OTN forums.
Next, when you post your question, ensure you provide all the information that is needed for people to be able to help you. Read the FAQ posts which point to useful threads indicating what information is required, especially for tuning requests.
Finally, when your questions have been answered, it is common courtesy to mark them as answered (and award points if appropriate), otherwise it indicates that you have no respect for the people who are helping you.
If you follow all the advice above, you will end up creating a good question that people will be willing to help you with. If you don't follow the advice above, such as in this question you've posted, you will find that few experts will bother to help (or if they post it will not likely be helpful advise you receive). The choice is yours. -
Hi all,
I am monitoring the flight information message.
Now we plan to alert a message if the flight information message were not get last 5 minutes comparewith Sysdate(Current system date and time).
Here the query :
SELECT MESSAGE,MESSAGE_DATE_TIME FROM UMESSAGE
Message Message_Date_Time
DUBAI 24/02/2009 11:39:16
ATHENS 24/02/2009 11:30:03
For example now the current date_time is 24/02/2009 11:45:16
The last message we got is 24/02/2009 11:39:16
After that message we did not get any message.It is almost more than 5 minutes.
Now I want to combine both the query .
SELECT SYSDATE FROM DUAL
SELECT MESSAGE,MESSAGE_DATE_TIME FROM UMESSAGE
how will I get it?
Please help.Hi Rahul,
SQL> with umessage as (select 'DUBAI' message
,to_date('24/02/2009 11:39:16', 'dd/mm/yyyy hh24:mi:ss') message_date_time
from dual
union all
select 'ATHENS' message
,to_date('24/02/2008 11:30:03', 'dd/mm/yyyy hh24:mi:ss') message_date_time
from dual)
-- end of test data
select case
when (sysdate - max(message_date_time)) * 24 * 60 > 5 then 'Alert'
else 'Msgs Comming'
end
from umessage
CASEWHEN(SYS
Msgs Comming
1 row selected.Hint: We haven't heard from Athens in a year.
Regards
Peter -
Need help th tuning query or re write the query--
Hi,
Need help to tune the below query or rewrite th query for reducing the execution time Please find the query and explain plan.
QUERY
explain plan FOR SELECT consumer_key,product_key,days_in_product,20100201 period_key FROM
(SELECT consumer_key,
product_key,
days_in_product,
row_number() over ( Partition BY consumer_key order by Days_in_product DESC) row_num
FROM
(SELECT consumer_key,
product_key,
SUM(no_ofdays) days_in_product
FROM
(SELECT pcv.consumer_key,
pcv.product_key,
pcv.product_consumer_valid_from,
pcv.product_consumer_valid_to,
DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from) period_start,
DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959) period_end,
CASE
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) BETWEEN 20100201000000 AND 20100228235959
AND activation_date > to_Date(product_consumer_valid_to,'YYYYMMDDHH24MISS')
THEN 0
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) BETWEEN 20100201000000 AND 20100228235959
AND activation_date BETWEEN to_Date(product_consumer_valid_from,'YYYYMMDDHH24MISS') AND to_Date(product_consumer_valid_to,'YYYYMMDDHH24MISS')
THEN
--to_char(activation_date,'MON-YYYY')='PERIOD_ACTIVE' and activation_date >= to_Date(product_consumer_valid_from,'YYYYMMDDHH24MISS') then
(to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_date(TO_CHAR(activation_date,'YYYYMMDDHH24MISS'),'YYYYMMDDHH24MISS') )
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) < 20100201000000
THEN (to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_Date(DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from),'YYYYMMDDHH24MISS') )
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) > 20100228235959
THEN 0
ELSE
--unusual situation
(to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_Date(DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from),'YYYYMMDDHH24MISS') )
END No_ofDays
FROM cimtran.product_consumer_validity pcv,
consumer_dimension cd
WHERE pcv.consumer_key =cd.consumer_key
AND product_consumer_valid_to >= 20100201000000
AND product_consumer_valid_from <= 20100228235959
--and product_consumer_valid_from > '20090801000000'
ORDER BY consumer_key,
product_key,
product_consumer_valid_from
) a
GROUP BY consumer_key,
product_key
ORDER BY consumer_key,
product_key
) WHERE row_num=1 ;EXPLAIN PLAN
"PLAN_TABLE_OUTPUT"
"Plan hash value: 3823907703"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 4665K| 231M| | 133K (1)| 00:31:08 |"
"|* 1 | VIEW | | 4665K| 231M| | 133K (1)| 00:31:08 |"
"|* 2 | WINDOW SORT PUSHED RANK| | 4665K| 173M| 232M| 133K (1)| 00:31:08 |"
"| 3 | VIEW | | 4665K| 173M| | 104K (1)| 00:24:18 |"
"| 4 | SORT GROUP BY | | 4665K| 182M| 729M| 104K (1)| 00:24:18 |"
"|* 5 | HASH JOIN | | 13M| 533M| 65M| 44241 (1)| 00:10:20 |"
"| 6 | TABLE ACCESS FULL | CONSUMER_DIMENSION | 2657K| 35M| | 4337 (1)| 00:01:01 |"
"|* 7 | TABLE ACCESS FULL | PRODUCT_CONSUMER_VALIDITY | 13M| 351M| | 15340 (2)| 00:03:35 |"
"Predicate Information (identified by operation id):"
" 1 - filter(""ROW_NUM""=1)"
" 2 - filter(ROW_NUMBER() OVER ( PARTITION BY ""CONSUMER_KEY"" ORDER BY "
" INTERNAL_FUNCTION(""DAYS_IN_PRODUCT"") DESC )<=1)"
" 5 - access(""PCV"".""CONSUMER_KEY""=""CD"".""CONSUMER_KEY"")"
" 7 - filter(""PRODUCT_CONSUMER_VALID_FROM""<=20100228235959 AND "
" ""PRODUCT_CONSUMER_VALID_TO"">=20100201000000)"I doubt that this query can be tuned without using indexes. There is a lot of unnecessary work specified in your query, like unnecessary intermediate sorting and selecting unused columns. The cost based optimizer recognized it and skips some of that unnecessary work, it seems. For clarity's sake, I would rewrite your query like below. Note that the query is untested:
select consumer_key
, max(product_key) keep (dense_rank last order by days_in_product) product_key
, max(days_in_product) days_in_product
, 20100201 period_key
from ( select pcv.consumer_key
, pcv.product_key
, sum
( case
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) between 20100201000000 and 20100228235959
then
case
when cd.activation_date > to_date(pcv.product_consumer_valid_to,'yyyymmddhh24miss')
then
0
when cd.activation_date between to_date(pcv.product_consumer_valid_from,'yyyymmddhh24miss') and to_date(product_consumer_valid_to,'yyyymmddhh24miss')
then
to_date(to_char(pcv.product_consumer_valid_to),'yyyymmddhh24miss'))
- to_date(to_char(activation_date,'yyyymmddhh24miss'),'yyyymmddhh24miss')
end
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) < 20100201000000
then
to_date(to_char(pcv.product_consumer_valid_to),'yyyymmddhh24miss'))
- to_date(to_char(pcv.product_consumer_valid_from),'yyyymmddhh24miss'))
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) > 20100228235959
then
0
end
) days_in_product
from cimtran.product_consumer_validity pcv
, consumer_dimension cd
where pcv.consumer_key = cd.consumer_key
and product_consumer_valid_to >= 20100201000000
and product_consumer_valid_from <= 20100228235959
group by consumer_key
, product_key
group by consumer_keyRegards,
Rob. -
Hi all
I want to fetch just twenty thousands records from table. My query take more time to fetch twenty thousands records. I post my working query, Could you correct the query for me. thanks in advance.
Query
select
b.Concatenated_account Account,
b.Account_description description,
SUM(case when(Bl.ACTUAL_FLAG='B') then
((NVL(Bl.PERIOD_NET_DR, 0)- NVL(Bl.PERIOD_NET_CR, 0)) + (NVL(Bl.PROJECT_TO_DATE_DR, 0)- NVL(Bl.PROJECT_TO_DATE_CR, 0)))end) "Budget_2011"
from
gl_balances Bl,
gl_code_combinations GCC,
psb_ws_line_balances_i b ,
gl_budget_versions bv,
gl_budgets_v gv
where
b.CODE_COMBINATION_ID=gcc.CODE_COMBINATION_ID and bl.CODE_COMBINATION_ID=gcc.CODE_COMBINATION_ID and
bl.budget_version_id =bv.BUDGET_VERSION_ID and gv.budget_version_id= bv.budget_version_id
and gv.latest_opened_year in (select latest_opened_year-3 from gl_budgets_v where latest_opened_year=:BUDGET_YEAR )
group by b.Concatenated_account ,b.Account_descriptionHi,
If this question is related to SQL then please post in SQL forum.
Otherwise provide more information how this sql is being used and do you want to tune the SQL or the way it fetches the information from DB and display in OAF.
Regards,
Sandeep M. -
In ST03 , how can i see the Query name, user id,how many times executed the
HI Experts,
In ST03 , how can i see the Query name, user id,how many times executed the query.
these details how do i get from the above transaction.
EX:-if there is one report name X,I want to know how many users had executed X report today,weekly,monthly.
ex:-query userid total number of execution
sales order 0000555 5 times
custmer 05855 2 times
fast reply will be appreciated,Hi,
Look here:
http://help.sap.com/saphelp_nw04/helpdata/en/3b/54df4204892a78e10000000a155106/frameset.htm
Also check these:
http://help.sap.com/saphelp_nw2004s/helpdata/en/2d/b8be3befaefc75e10000000a114084/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/25/ece73a39e74d27e10000000a114084/frameset.htm
Hope this helps..
Bye
Dinesh -
In ST03 , how can i see the Query name, user id,how many times .
HI Experts,
In ST03 , how can i see the Query name, user id,how many times executed the query.
these details how do i get from the above transaction.
Points will be awarded.
BR
sivsHi Siva,
Reporting statistics data is only written to the database table if BW statistics have been manually activated for the corresponding InfoProvider first. If this has not been done, it is therefore not possible to display any reporting statistics in transaction ST03.
Therefore activate the reporting statistics for all relevant InfoProviders. To do this, set the OLAP flag in the BW Administrator Workbench (transaction RSA1) in the area Tools ® BW Statistics for InfoProvider.
Check here...........
http://help.sap.com/saphelp_nw04/helpdata/en/ca/86df4254d81e1fe10000000a155106/content.htm
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c8c4d794-0501-0010-a693-918a17e663cc
Hope this will help you shiva.........
Regrads,
Vijay -
While running the query how much time it will taken, I want to see the time
Hi Folks
I would like to know ... While running the query how much time it will be taken, I want to see the time? in WEBI XI R2.....
Plz let me know the answer.......Hi Ravi,
The time a report runs is estimated based on the last time it was run. So you need to run the report once before you can see how long it will take. Also it depends on several factors... the database server could cache some queries so running it a second time immediately after the first time could be quicker. And there is the chance of changing filters to bring back different sets of data.
You could also schedule a report and then check the scheduled instance's status properties and view how long a report actually ran.
Good luck -
Return value from database function taking a lot more time than the query
Hi guys,
I have a Query that does a call to a database function. The function takes in a few parameters and returns a Date. Now, the query within the function takes barely .05 seconds. However, doing a select get_join_dates from dual is taking almost 6 seconds for each call.
Here is the Query:
select s.student_id, s.student_name, s.organization_code
from student s
where s.student_id = :p_student_id
and s.student_enrollment_date = get_join_dates( :p_year,
:p_month,
:p_student_id,
s.organization_code );And here is the database function. The select inside this function barely takes 0.05 seconds per call. This function gets called 3 times in my case as there are 3 records in the org_body table for this student.
create or replace function
get_join_dates( p_yyyy in org_body.fiscal_yyyy%type,
p_month in org_body.fiscal_mm%type,
p_student_id in student.student_id%type,
p_organization_code in org_body.organization_code%type) return date as
t_enrollment_date date;
cursor cur_latest_enrollment_date is
select max(enrollment_date)
from org_body
where fiscal_yyyy = p_yyyy
and fiscal_mm = p_month
and student_id = p_student_id
and organization_code = p_organization_code;
BEGIN
open cur_latest_enrollment_date ;
fetch cur_latest_enrollment_date into t_enrollment_date;
close cur_latest_enrollment_date ;
return t_enrollment_date;
exception
when others then
null;
end;owever, when I run the following statement below, it takes close to 6 seconds to retrieve a record. In turn, my Query is becoming really slow and taking almost 35 seconds. Imagine that with more records.
select get_join_dates( 2010, '01', '2167543', 'PSYCH01' ) from dual;If I run my query with this condition below, it takes 0.5 seconds.
select s.student_id, s.student_name, s.organization_code
from student s
where s.student_id = :p_student_id
and s.student_enrollment_date = '01-JAN-10'Any ideas would be greatly appreciated.Any reason why you are doing this with the stored function?
You could just do this with SQL. Embed the query in the function as a subquery in your initial query from STUDENT.
select s.student_id, s.student_name, s.organization_code
from student s
where s.student_id = :p_student_id
and s.student_enrollment_date =
(select max(enrollment_date)
from org_body
where fiscal_yyyy = :p_year
and fiscal_mm = :p_month
and student_id = s.student_id
and organization_code = s.organization_code);Why your function is not performing: I cannot say that with the information you have provided.
Maybe sqltrace a call and see what the reason is. -
Query taking long time To Fectch the Results
Hi!
when I run the query,it takes too long time for fetching the resultsets.
Please find the query below for the same.
SELECT
A.BUSINESS_UNIT,
A.JOURNAL_ID,
TO_CHAR(A.JOURNAL_DATE,'YYYY-MM-DD'),
A.UNPOST_SEQ,
A.FISCAL_YEAR,
A.ACCOUNTING_PERIOD,
A.JRNL_HDR_STATUS,
C.INVOICE,
C.ACCT_ENTRY_TYPE,
C.LINE_DST_SEQ_NUM,
C.TAX_AUTHORITY_CD,
C.ACCOUNT,
C.MONETARY_AMOUNT,
D.BILL_SOURCE_ID,
D.IDENTIFIER,
D.VAT_AMT_BSE,
D.VAT_TRANS_AMT_BSE,
D.VAT_TXN_TYPE_CD,
D.TAX_CD_VAT,
D.TAX_CD_VAT_PCT,
D.VAT_APPLICABILITY,
E.BILL_TO_CUST_ID,
E.BILL_STATUS,
E.BILL_CYCLE_ID,
TO_CHAR(E.INVOICE_DT,'YYYY-MM-DD'),
TO_CHAR(E.ACCOUNTING_DT,'YYYY-MM-DD'),
TO_CHAR(E.DT_INVOICED,'YYYY-MM-DD'),
E.ENTRY_TYPE,
E.ENTRY_REASON,
E.AR_LVL,
E.AR_DST_OPT,
E.AR_ENTRY_CREATED,
E.GEN_AR_ITEM_FLG,
E.GL_LVL, E.GL_ENTRY_CREATED,
(Case when c.account in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','90100000')
and D.TAX_CD_VAT_PCT <> 0 then 'Ej_Momskonto_med_moms'
When c.account not in ('30120000','30180050','30190000','30290000',
'30490000','30690000','30900040','30990000','35100000','35120000','35150000',
'35160000','39100050','90100000')
and D.TAX_CD_VAT_PCT <> 25 then 'Momskonto_utan_moms' end)
FROM
sysadm.PS_JRNL_HEADER A,
sysadm.PS_JRNL_LN B,
sysadm.PS_BI_ACCT_ENTRY C,
sysadm.PS_BI_LINE D,
sysadm.PS_BI_HDR E
WHERE A.BUSINESS_UNIT = '&BU'
AND A.JOURNAL_DATE BETWEEN TO_DATE('&From_date','YYYY-MM-DD')
AND TO_DATE('&To_date','YYYY-MM-DD')
AND A.SOURCE = 'BI'
AND A.BUSINESS_UNIT = B.BUSINESS_UNIT
AND A.JOURNAL_ID = B.JOURNAL_ID
AND A.JOURNAL_DATE = B.JOURNAL_DATE
AND A.UNPOST_SEQ = B.UNPOST_SEQ
AND B.BUSINESS_UNIT = C.BUSINESS_UNIT
AND B.JOURNAL_ID = C.JOURNAL_ID
AND B.JOURNAL_DATE = C.JOURNAL_DATE
AND B.JOURNAL_LINE = C.JOURNAL_LINE
AND C.ACCT_ENTRY_TYPE = 'RR'
AND C.BUSINESS_UNIT = '&BU'
AND C.BUSINESS_UNIT = D.BUSINESS_UNIT
AND C.INVOICE = D.INVOICE
AND C.LINE_SEQ_NUM = D.LINE_SEQ_NUM
AND D.BUSINESS_UNIT = '&BU'
AND D.BUSINESS_UNIT = E.BUSINESS_UNIT
AND D.INVOICE = E.INVOICE
AND E.BUSINESS_UNIT = '&BU'
AND
((c.account in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','90100000')
and D.TAX_CD_VAT_PCT <> 0)
OR
(c.account not in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','z')
and D.TAX_CD_VAT_PCT <> 25)
GROUP BY
A.BUSINESS_UNIT,
A.JOURNAL_ID,
TO_CHAR(A.JOURNAL_DATE,'YYYY-MM-DD'),
A.UNPOST_SEQ, A.FISCAL_YEAR,
A.ACCOUNTING_PERIOD,
A.JRNL_HDR_STATUS,
C.INVOICE,
C.ACCT_ENTRY_TYPE,
C.LINE_DST_SEQ_NUM,
C.TAX_AUTHORITY_CD,
C.ACCOUNT,
D.BILL_SOURCE_ID,
D.IDENTIFIER,
D.VAT_TXN_TYPE_CD,
D.TAX_CD_VAT,
D.TAX_CD_VAT_PCT,
D.VAT_APPLICABILITY,
E.BILL_TO_CUST_ID,
E.BILL_STATUS,
E.BILL_CYCLE_ID,
TO_CHAR(E.INVOICE_DT,'YYYY-MM-DD'),
TO_CHAR(E.ACCOUNTING_DT,'YYYY-MM-DD'),
TO_CHAR(E.DT_INVOICED,'YYYY-MM-DD'),
E.ENTRY_TYPE, E.ENTRY_REASON,
E.AR_LVL, E.AR_DST_OPT,
E.AR_ENTRY_CREATED,
E.GEN_AR_ITEM_FLG,
E.GL_LVL,
E.GL_ENTRY_CREATED,
C.MONETARY_AMOUNT,
D.VAT_AMT_BSE,
D.VAT_TRANS_AMT_BSE
having
(Case when c.account in ('30120000','30180050','30190000','30290000',
'30490000','30690000','30900040','30990000','35100000','35120000','35150000',
'35160000','39100050','90100000')
and D.TAX_CD_VAT_PCT <> 0 then 'Ej_Momskonto_med_moms'
When c.account not in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','90100000')
and D.TAX_CD_VAT_PCT <> 25 then 'Momskonto_utan_moms' end) is not null
So Could you provide the solution to fix this issue?
Thanks
senthil[url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]When your query takes too long ...
Regards,
Rob. -
Query taking long time for EXTRACTING the data more than 24 hours
Hi ,
Query taking long time for EXTRACTING the data more than 24 hours please find the query and explain plan details below even indexes avilable on table's goe's to FULL TABLE SCAN. please suggest me.......
SQL> explain plan for select a.account_id,round(a.account_balance,2) account_balance,
2 nvl(ah.invoice_id,ah.adjustment_id) transaction_id,
to_char(ah.effective_start_date,'DD-MON-YYYY') transaction_date,
to_char(nvl(i.payment_due_date,
to_date('30-12-9999','dd-mm-yyyy')),'DD-MON-YYYY')
due_date, ah.current_balance-ah.previous_balance amount,
decode(ah.invoice_id,null,'A','I') transaction_type
3 4 5 6 7 8 from account a,account_history ah,invoice i_+
where a.account_id=ah.account_id
and a.account_type_id=1000002
and round(a.account_balance,2) > 0
and (ah.invoice_id is not null or ah.adjustment_id is not null)
and ah.CURRENT_BALANCE > ah.previous_balance
and ah.invoice_id=i.invoice_id(+)
AND a.account_balance > 0
order by a.account_id,ah.effective_start_date desc; 9 10 11 12 13 14 15 16
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | SELECT STATEMENT | | 544K| 30M| | 693K (20)|
| 1 | SORT ORDER BY | | 544K| 30M| 75M| 693K (20)|
|* 2 | HASH JOIN | | 544K| 30M| | 689K (20)|
|* 3 | TABLE ACCESS FULL | ACCOUNT | 20080 | 294K| | 6220 (18)|
|* 4 | HASH JOIN OUTER | | 131M| 5532M| 5155M| 678K (20)|
|* 5 | TABLE ACCESS FULL| ACCOUNT_HISTORY | 131M| 3646M| | 197K (25)|
| 6 | TABLE ACCESS FULL| INVOICE | 262M| 3758M| | 306K (18)|
Predicate Information (identified by operation id):
2 - access("A"."ACCOUNT_ID"="AH"."ACCOUNT_ID")
3 - filter("A"."ACCOUNT_TYPE_ID"=1000002 AND "A"."ACCOUNT_BALANCE">0 AND
ROUND("A"."ACCOUNT_BALANCE",2)>0)
4 - access("AH"."INVOICE_ID"="I"."INVOICE_ID"(+))
5 - filter("AH"."CURRENT_BALANCE">"AH"."PREVIOUS_BALANCE" AND ("AH"."INVOICE_ID"
IS NOT NULL OR "AH"."ADJUSTMENT_ID" IS NOT NULL))
22 rows selected.
Index Details:+_
SQL> select INDEX_OWNER,INDEX_NAME,COLUMN_NAME,TABLE_NAME from dba_ind_columns where
2 table_name in ('INVOICE','ACCOUNT','ACCOUNT_HISTORY') order by 4;
INDEX_OWNER INDEX_NAME COLUMN_NAME TABLE_NAME
OPS$SVM_SRV4 P_ACCOUNT ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME ACCOUNT_NAME ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT CUSTOMER_NODE_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT ACCOUNT_TYPE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_ACCOUNT_TYPE ACCOUNT_TYPE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_INVOICE INVOICE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_PREVIOUS_INVOICE PREVIOUS_INVOICE_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_NAME ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 I_LAST_MODIFIED_ACCOUNT LAST_MODIFIED ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_INVOICE_ACCOUNT INVOICE_ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT ACCOUNT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT SEQNR ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_INVOICE INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA CURRENT_BALANCE ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ACCOUNT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_LMOD LAST_MODIFIED ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_PAYMENT PAYMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADJUSTMENT ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_APPLIED_DT APPLIED_DATE ACCOUNT_HISTORY
OPS$SVM_SRV4 P_INVOICE INVOICE_ID INVOICE
OPS$SVM_SRV4 U_INVOICE CUSTOMER_INVOICE_STR INVOICE
OPS$SVM_SRV4 I_LAST_MODIFIED_INVOICE LAST_MODIFIED INVOICE
OPS$SVM_SRV4 U_INVOICE_ACCOUNT ACCOUNT_ID INVOICE
OPS$SVM_SRV4 U_INVOICE_ACCOUNT BILL_RUN_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_BILL_RUN BILL_RUN_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_INVOICE_TYPE INVOICE_TYPE_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_CUSTOMER_NODE CUSTOMER_NODE_ID INVOICE
32 rows selected.
Regards,
Bathula
Oracle-DBAI have some suggestions. But first, you realize that you have some redundant indexes, right? You have an index on account(account_name) and also account(account_name, account_id), and also account_history(invoice_id) and account_history(invoice_id, adjustment_id). No matter, I will suggest some new composite indexes.
Also, you do not need two lines for these conditions:
and round(a.account_balance, 2) > 0
AND a.account_balance > 0
You can just use: and a.account_balance >= 0.005
So the formatted query isselect a.account_id,
round(a.account_balance, 2) account_balance,
nvl(ah.invoice_id, ah.adjustment_id) transaction_id,
to_char(ah.effective_start_date, 'DD-MON-YYYY') transaction_date,
to_char(nvl(i.payment_due_date, to_date('30-12-9999', 'dd-mm-yyyy')),
'DD-MON-YYYY') due_date,
ah.current_balance - ah.previous_balance amount,
decode(ah.invoice_id, null, 'A', 'I') transaction_type
from account a, account_history ah, invoice i
where a.account_id = ah.account_id
and a.account_type_id = 1000002
and (ah.invoice_id is not null or ah.adjustment_id is not null)
and ah.CURRENT_BALANCE > ah.previous_balance
and ah.invoice_id = i.invoice_id(+)
AND a.account_balance >= .005
order by a.account_id, ah.effective_start_date desc;You will probably want to select:
1. From ACCOUNT first (your smaller table), for which you supply a literal on account_type_id. That should limit the accounts retrieved from ACCOUNT_HISTORY
2. From ACCOUNT_HISTORY. We want to limit the records as much as possible on this table because of the outer join.
3. INVOICE we want to access last because it seems to be least restricted, it is the biggest, and it has the outer join condition so it will manufacture rows to match as many rows as come back from account_history.
Try the query above after creating the following composite indexes. The order of the columns is important:create index account_composite_i on account(account_type_id, account_balance, account_id);
create index acct_history_comp_i on account_history(account_id, invoice_id, adjustment_id, current_balance, previous_balance, effective_start_date);
create index invoice_composite_i on invoice(invoice_id, payment_due_date);All the columns used in the where clause will be indexed, in a logical order suited to the needs of the query. Plus each selected column is indexed as well so that we should not need to touch the tables at all to satisfy the query.
Try the query after creating these indexes.
A final suggestion is to try larger sort and hash area sizes and a manual workarea policy.alter session set workarea_size_policy = manual;
alter session set sort_area_size = 2147483647;
alter session set hash_area_size = 2147483647; -
Help required in optimizing the query response time
Hi,
I am working on a application which uses a jdbc thin client. My requirement is to select all the table rows in one table and use the column values to select data in another table in another database.
The first table can have maximum of 6 million rows but the second table rows will be around 9000.
My first query is returning within 30-40 milliseconds when the table is having 200000 rows. But when I am iterating the result set and query the second table the query is taking around 4 millisecond for each query.
the second query selection criteria is to find the value in the range .
for example my_table ( varchar2 column1, varchar2 start_range, varchar2 end_range);
My first query returns a result which then will be used to select using the following query
select column1 from my_table where start_range < my_value and end_range> my_value;
I have created an index on start_range and end_range. this query is taking around 4 millisseconds which I think is too much.
I am using a preparedStatement for the second query loop.
Can some one suggest me how I can improve the query response time?
Regards,
ShyamTry the code below.
Pre-requistee: you should know how to pass ARRAY objects to oracle and receive resultsets from java. There are 1000s of samples available on net.
I have written a sample db code for the same interraction.
Procedure get_list takes a array input from java and returns the record set back to java. You can change the tablenames and the creteria.
Good luck.
DROP TYPE idlist;
CREATE OR REPLACE TYPE idlist AS TABLE OF NUMBER;
CREATE OR REPLACE PACKAGE mypkg1
AS
PROCEDURE get_list (myval_list idlist, orefcur OUT sys_refcursor);
END mypkg1;
CREATE OR REPLACE PACKAGE BODY mypkg1
AS
PROCEDURE get_list (myval_list idlist, orefcur OUT sys_refcursor)
AS
ctr NUMBER;
BEGIN
DBMS_OUTPUT.put_line (myval_list.COUNT);
FOR x IN (SELECT object_name, object_id, myvalue
FROM user_objects a,
(SELECT myval_list (ROWNUM + 1) myvalue
FROM TABLE (myval_list)) b
WHERE a.object_id < b.myvalue)
LOOP
DBMS_OUTPUT.put_line ( x.object_name
|| ' - '
|| x.object_id
|| ' - '
|| x.myvalue
END LOOP;
END;
END mypkg1;
[pre]
Testing the code above. Make sure dbms output is ON.
[pre]
DECLARE
a idlist;
refc sys_refcursor;
c number;
BEGIN
SELECT x.nu
BULK COLLECT INTO a
FROM (SELECT 5000 nu
FROM DUAL) x;
mypkg1.get_list (a, refc);
END;
[pre]
Vishal V.
Maybe you are looking for
-
Full folder names don't show.
In iOS, file/folder names are shortened when they cannot be displayed in one line. However, viewing a folder name within a folder still shows its shortened name. The expected result is that it should show its full, non-shortened name. "Cloud File Man
-
Delivery date in MIRO - PO reference
I would like to see the delivery date (posting date in the GR document) in the MIRO transaction under PO reference. There is a delivery date that appears in the All information layout, but that refers to the expected delivery date. Please advise.
-
How can I convert adobe reader and all its contents in my files to acrobat
I have been wanting to convert all my adobe reader on file. I want them all in acrobat.com.
-
Why does labview 2009 32-bit closes up with no error message?
Hello. I am developing an application using a PCI-6534 board, Windows XP SP3, and LabVIEW 2009 32-bits. In this application I am generating a 300 Hz signal using the P2.0 digital line. I am trying to make digital acquisition using the P0 port (8 bits
-
When I try to authorize a second computer to download books I get this error message
"You can only authorize this computer with an Adobe Id that hasn't been previously used to authorize any other computer or mobile device" I thought I could have several computers authorized at one time