SQL query slow when issued by app, fast when issued mnaually
Hi there,
I have a more general question about a specific Oracle behaviour.
I update a feature from within an application. The application doesn't respond and I finally have to terminate it. I checked Oracle whether a query is running long using the following statement:
select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s
join v$sqltext_with_newlines q
on s.sql_address = q.address
where status='ACTIVE'
and type <>'BACKGROUND'
and last_call_et> 60
order by sid,serial#,q.piece
The result of the above query is:
WITH CONNECTION AS ( SELECT * FROM WW_CONN C WHERE (C.FID_FROM I
N (SELECT FID FROM WW_LINE WHERE FID_ATTR=:B1 ) AND C.F_CLASS_ID
FROM =22) OR (C.FIDTO IN (SELECT FID FROM WW_LINE WHERE FID_AT
TR=:B1 ) AND C.F_CLASS_ID_TO =22) ) SELECT MIN(P.FID_ATTR) AS FI
D_FROM FROM CONNECTION C, WW_POINT P WHERE (P.FID = C.FID_FROM A
ND C.F_CLASS_ID_FROM = 32 AND C.FLOW = 1) OR (P.FID = C.FID_TO A
ND C.F_CLASS_ID_TO = 32 AND C.FLOW = 2)
I have a different tool which shows me the binding parameter values. So I know that the value for :B1 is 5011 - the id of the feature being updated. This query runs for 20 mins and longer before it eventually stops. The update process involves multiple sql statements - so this one is not doing the update but is part of the process.
Here is the bit I do not understand: when I run the query in SQL Developer with value 5011 for :B1 it takes 0.5 secs to return a result.
Why is it, that the sql statement takes so long when issued by the application but takes less than a second when I run it manually?
I sent a dump of the data to the application vendor who is not able to reproduce the issue in their environment. Could someone explain to me what happens here or give me some keywords for further research?
We are using 11gR2, 64bit.
Many thanks,
Rob
Hi Rob,
at least you should see some differences in the statistics for the different child cursor (the one for the execution in the application should show at least a higher value for ELAPSED_TIME). I would use something like the following query to check the information for the child cursors:
select sql_id
, PLAN_HASH_VALUE
, CHILD_NUMBER
, EXECUTIONS
, ELAPSED_TIME
, USER_IO_WAIT_TIME
, CONCURRENCY_WAIT_TIME
, DISK_READS
, BUFFER_GETS
, ROWS_PROCESSED
from v$sql
where sql_id = your_sql_idRegards
Martin
Similar Messages
-
Sql query slowness due to rank and columns with null values:
Sql query slowness due to rank and columns with null values:
I have the following table in database with around 10 millions records:
Declaration:
create table PropertyOwners (
[Key] int not null primary key,
PropertyKey int not null,
BoughtDate DateTime,
OwnerKey int null,
GroupKey int null
go
[Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
With the following index:
CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]
[PropertyKey] ASC,
[BoughtDate] DESC,
[OwnerKey] DESC,
[GroupKey] DESC
go
Description of the case:
For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
declare @ownerKey int = 40000
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from (
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
) as result
where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
May be the slowness is due to as OwnerKey/GroupKey in the table can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
view.
Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
go
declare @ownerKey int = 1
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from #result as result
where result.[Rank]=1
and result.[OwnerKey]=@ownerKey
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Sql query slow in new redhat enviornment
We just migrated to a new dev environment in Linux REDHAT5, and now the query is very slow, and I used the TOAD to run the query, it took like 700 msecond to finish, however from any server connection, the sql query takes hours to finish.
I checked toad monitor, it said need to increase db_buffer_cache and shared pool too small.
Also three red alert from toad is:
1. Library Cache get hit ratio: Dynamic or unsharable sql
2. Chained fetch ratio: PCT free too low for a table
3. parse to execute ratio: HIgh parse to execute ratio.
App team said it ran real quick in the old AIX system, however I ran it in old system, and monitored in the toad, it gave me all same 5 red alerts in old system, and it did provide query results a lot quicker though.
Here is the parameters in the old system (11gr1 on AIX):
SQL> show parameter target
NAME TYPE VALUE
-------------------------------- archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 0
memory_target big integer 0
pga_aggregate_target big integer 278928K
sga_target big integer 0
SQL> show parameter shared
NAME TYPE VALUE
-------------------------------- hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 31876710
shared_pool_size big integer 608M
shared_server_sessions integer
shared_servers integer 0
SQL> show parameter db_buffer
SQL> show parameter buffer
NAME TYPE VALUE
-------------------------------- buffer_pool_keep string
buffer_pool_recycle string
db_block_buffers integer 0
log_buffer integer 2048000
use_indirect_data_buffers boolean FALSE
SQL>
In new 11gr2 Linux REDHAT parameter:
NAME TYPE VALUE
----------- archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 2512M
memory_target big integer 2512M
parallel_servers_target integer 192
pga_aggregate_target big integer 0
sga_target big integer 1648M
SQL> show parameter shared
NAME TYPE VALUE
----------- hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 28M
shared_pool_size big integer 0
shared_server_sessions integer
shared_servers integer 1
SQL> show parameter buffer
NAME TYPE VALUE
----------- buffer_pool_keep string
buffer_pool_recycle string
db_block_buffers integer 0
log_buffer integer 18857984
use_indirect_data_buffers boolean FALSE
SQL>
Please help. Thanks in advance.846422 wrote:
why need ddl? we have a sql query slow.The DDL shows the physical structure of the table and physical storage characteristics. All relevant in performance tuning.
As for the SQL query being slow. It is not.
You have not provided any evidence that it is slow. And no, comparing performance with a totally different system is not a valid baseline for comparison. (most cars have 4 wheels, a gearbox and a steering wheel - but that does not mean you can compare different cars like a VW Beetle with a VW Porsche)
What is slow? What are the biggest wait states for the SQL? What does the execution plan say?
You have not defined a problem - you identified a symptom called "+query is slow+". You need to diagnose the condition by determining exactly what the SQL qeury is doing in the database. (and please, do not use TOAD and similar tools in an attempt to do this - do it properly instead) -
Music pauses on my iPhone 5C when switching between apps or when receiving alerts/notifications sometimes (not always) and I have to manually restart the song. I'm running the latest 7.0.1 software. It's a bit annoying.
I have had a similar problem with my system. I just recently (within a week of this post) built a brand new desktop. I installed Windows 7 64-bit Home and had a clean install, no problems. Using IE downloaded an anti-virus program, and then, because it was the latest version, downloaded and installed Firefox 4.0. As I began to search the internet for other programs to install after about maybe 10-15 minutes my computer crashes. Blank screen (yet monitor was still receiving a signal from computer) and completely frozen (couldn't even change the caps and num lock on keyboard). I thought I perhaps forgot to reboot after an update so I did a manual reboot and it started up fine.
When ever I got on the internet (still using firefox) it would crash after anywhere between 5-15 minutes. Since I've had good experience with FF in the past I thought it must be either the drivers or a hardware problem. So in-between crashes I updated all the drivers. Still had the same problem. Took the computer to a friend who knows more about computers than I do, made sure all the drivers were updated, same problem. We thought that it might be a hardware problem (bad video card, chipset, overheating issues, etc.), but after my friend played around with my computer for a day he found that when he didn't start FF at all it worked fine, even after watching a movie, or going through a playlist on Youtube.
At the time of this posting I'm going to try to uninstall FF 4.0 and download and install FF 3.6.16 which is currently on my laptop and works like a dream. Hopefully that will do the trick, because I love using FF and would hate to have to switch to another browser. Hopefully Mozilla will work out the kinks with FF 4 so I can continue to use it.
I apologize for the lengthy post. Any feedback would be appreciated, but is not necessary. I will try and post back after I try FF 3.16.6. -
I changed my Apple ID it works when purchasing new apps but when I have updates for my apps my old Apple ID pops up and I can not update, how do I fix this?
If you changed your Apple ID. It should work for new purchases or updates. If you created a new ID, then you have to use the old ID and password in order to update the apps. Purchases are forever tied to the ID used to make the purchase and ID's cannot be combined nor can the purchases.
If you need to sign I to your old ID go to Settings>iTunes & App Store>Apple ID. Tap the ID and sign out, and sign in with the other ID. -
Sql query slow due to case statement on Joins
Hi
The sql query runs very slow for 30 min when the below case statement is added on the joins. Could you please let me know how to tune it. if the case statement is not there then it runs only for 1 min.
*( CASE*
WHEN PO_DIST_GL_CODE_COMB.SEGMENT2 <> '1000'
THEN PO_DIST_GL_CODE_COMB.SEGMENT1 || PO_DIST_GL_CODE_COMB.SEGMENT2 || '_' || NVL(PO_DIST_GL_CODE_COMB.SEGMENT6,'000')
WHEN DT_REQ_ALL.EMPMGMTCD IS NOT NULL AND
PO_DIST_GL_CODE_COMB.SEGMENT2 = '1000'
THEN DT_REQ_ALL.EMPMGMTCD
END =DB2.DB2_FDW_MGMT_V.MH_CHILD )
SELECT DISTINCT
D.DB2_FDW_MGMT_V.RC_PARENT,
DT_REQ_ALL.FULL_NAME,
DT_REQ_ALL.EMP_COMPANY_CODE,
DT_REQ_ALL.EMP_COST_CENTER,
PO.PO_VENDORS.VENDOR_NAME,
PO_PO_HEADERS_ALL2.SEGMENT1,
PO_PO_HEADERS_ALL2.CREATION_DATE,
PO_DIST_GL_CODE_COMB.SEGMENT1,
PO_DIST_GL_CODE_COMB.SEGMENT2,
PO_PO_HEADERS_ALL2.CURRENCY_CODE,
PO_INV_DIST_ALL.INVOICE_NUM,
PO_INV_DIST_ALL.INVOICE_DATE,
(PO_INV_DIST_ALL.INVOICE_AMOUNT* PO_Rates_GL_DR.CONVERSION_RATE),
(NVL(to_number(PO_DIST_ALL.AMOUNT_BILLED),0) * PO_Rates_GL_DR.CONVERSION_RATE),
PO_LINES_LOC.LINE_NUM,
GL.GL_SETS_OF_BOOKS.NAME,
CASE
WHEN TRUNC(PO_PO_HEADERS_ALL2.CREATION_DATE) > PO_INV_DIST_ALL.INVOICE_DATE
THEN 1
ELSE 0
END ,
PO.PO_REQUISITION_LINES_ALL.LINE_LOCATION_ID,
TRUNC(PO_PO_HEADERS_ALL2.CREATION_DATE,'WW') + 8 WEEK_Ending
FROM
DB2.DB2_FDW_MGMT_V,
PO.PO_VENDORS,
PO.PO_HEADERS_ALL PO_PO_HEADERS_ALL2,
GL.GL_CODE_COMBINATIONS PO_DIST_GL_CODE_COMB,
AP.AP_INVOICES_ALL PO_INV_DIST_ALL,
PO.PO_DISTRIBUTIONS_ALL PO_DIST_ALL,
PO.PO_LINES_ALL PO_LINES_LOC,
GL.GL_SETS_OF_BOOKS,
PO.PO_REQUISITION_LINES_ALL,
PO.PO_LINE_LOCATIONS_ALL,
AP.AP_INVOICE_DISTRIBUTIONS_ALL PO_DIST_INV_DIST_ALL,
APPS.HR_OPERATING_UNITS,
PO.PO_REQ_DISTRIBUTIONS_ALL,
SELECT DISTINCT
PO_RDA.DISTRIBUTION_ID,
PO_RLA.requisition_line_id,
PO_RHA.DESCRIPTION PO_Descr,
PO_RHA.NOTE_TO_AUTHORIZER PO_Justification,
Req_Emp.FULL_NAME,
GL_CC.SEGMENT1 Req_Company_Code,
GL_CC.SEGMENT2 Req_Cost_Center,
Req_Emp_CC.SEGMENT1 Emp_Company_Code,
Req_Emp_CC.SEGMENT2 Emp_Cost_Center,
(Case
When GL_CC.SEGMENT2 <> 8000
Then TRUNC(GL_CC.SEGMENT1) || TRUNC(GL_CC.SEGMENT2) || '_' || NVL(GL_CC.SEGMENT6,'000')
Else TRUNC(Req_Emp_CC.SEGMENT1) || TRUNC(Req_Emp_CC.SEGMENT2) || '_' || NVL(Req_Emp_CC.SEGMENT6,'000')
End) EmpMgmtCD
FROM
PO.po_requisition_lines_all PO_rla,
PO.po_requisition_headers_all PO_rha,
PO.PO_REQ_DISTRIBUTIONS_ALL po_RDA,
GL.GL_CODE_COMBINATIONS gl_cc,
HR.PER_ALL_PEOPLE_F Req_Emp,
HR.PER_ALL_ASSIGNMENTS_F Req_Emp_Assign,
HR.hr_all_organization_units Req_Emp_Org,
HR.pay_cost_allocation_keyflex Req_Emp_CC
WHERE
PO_RDA.CODE_COMBINATION_ID = GL_CC.CODE_COMBINATION_ID and
PO_RLA.REQUISITION_LINE_ID = PO_RDA.REQUISITION_LINE_ID AND
PO_RLA.to_person_id = Req_Emp.PERSON_ID AND
PO_RLA.REQUISITION_HEADER_ID = PO_RHA.REQUISITION_HEADER_ID AND
(trunc(PO_rla.CREATION_DATE) between Req_Emp.effective_start_date and Req_Emp.effective_end_date OR
Req_Emp.effective_start_date IS NULL) AND
Req_Emp.PERSON_ID = Req_Emp_Assign.PERSON_ID AND
Req_Emp_Assign.organization_id = Req_Emp_Org.organization_id AND
(trunc(PO_rla.CREATION_DATE) between Req_Emp_Assign.effective_start_date and Req_Emp_Assign.effective_end_date OR
Req_Emp_Assign.effective_start_date IS NULL) AND
Req_Emp_Assign.primary_flag = 'Y' AND
Req_Emp_Assign.assignment_type = 'E' AND
Req_Emp_Org.cost_allocation_keyflex_id = Req_Emp_CC.cost_allocation_keyflex_id
) DT_REQ_ALL,
SELECT
FROM_CURRENCY,
TO_CURRENCY,
CONVERSION_DATE,
CONVERSION_RATE
FROM GL.GL_DAILY_RATES
UNION
SELECT Distinct
'USD',
'USD',
CONVERSION_DATE,
1
FROM GL.GL_DAILY_RATES
) PO_Rates_GL_DR
WHERE
( PO_DIST_GL_CODE_COMB.CODE_COMBINATION_ID=PO_DIST_ALL.CODE_COMBINATION_ID )
AND ( PO_DIST_ALL.LINE_LOCATION_ID=PO.PO_LINE_LOCATIONS_ALL.LINE_LOCATION_ID )
AND ( PO_PO_HEADERS_ALL2.VENDOR_ID=PO.PO_VENDORS.VENDOR_ID )
AND ( PO_PO_HEADERS_ALL2.ORG_ID=APPS.HR_OPERATING_UNITS.ORGANIZATION_ID )
AND ( GL.GL_SETS_OF_BOOKS.SET_OF_BOOKS_ID=APPS.HR_OPERATING_UNITS.SET_OF_BOOKS_ID )
AND ( PO_PO_HEADERS_ALL2.CURRENCY_CODE=PO_Rates_GL_DR.FROM_CURRENCY )
AND ( trunc(PO_PO_HEADERS_ALL2.CREATION_DATE)=PO_Rates_GL_DR.CONVERSION_DATE )
AND ( PO_DIST_ALL.REQ_DISTRIBUTION_ID=PO.PO_REQ_DISTRIBUTIONS_ALL.DISTRIBUTION_ID(+) )
AND ( PO.PO_REQ_DISTRIBUTIONS_ALL.REQUISITION_LINE_ID=PO.PO_REQUISITION_LINES_ALL.REQUISITION_LINE_ID(+) )
AND ( PO_LINES_LOC.PO_HEADER_ID=PO_PO_HEADERS_ALL2.PO_HEADER_ID )
AND ( PO.PO_LINE_LOCATIONS_ALL.PO_LINE_ID=PO_LINES_LOC.PO_LINE_ID )
AND ( PO_DIST_ALL.REQ_DISTRIBUTION_ID=DT_REQ_ALL.DISTRIBUTION_ID(+) )
AND ( PO_DIST_ALL.PO_DISTRIBUTION_ID=PO_DIST_INV_DIST_ALL.PO_DISTRIBUTION_ID(+) )
AND ( PO_INV_DIST_ALL.INVOICE_ID(+)=PO_DIST_INV_DIST_ALL.INVOICE_ID )
AND ( PO_INV_DIST_ALL.SOURCE(+) <> 'XML GATEWAY' )
AND
( NVL(PO_PO_HEADERS_ALL2.CANCEL_FLAG,'N') <> 'Y' )
AND
( NVL(PO_PO_HEADERS_ALL2.CLOSED_CODE, 'OPEN') <> 'FINALLY CLOSED' )
AND
( NVL(PO_PO_HEADERS_ALL2.AUTHORIZATION_STATUS,'IN PROCESS') <> 'REJECTED' )
AND
( TRUNC(PO_PO_HEADERS_ALL2.CREATION_DATE) BETWEEN TO_DATE('01-jan-2011') AND TO_DATE('04-jan-2011') )
AND
PO_Rates_GL_DR.TO_CURRENCY = 'USD'
AND
DB2.DB2_FDW_MGMT_V.RC_PARENT In ( 'Unavailable','Corp','Commercial' )
AND
( CASE
WHEN PO_DIST_GL_CODE_COMB.SEGMENT2 <> '1000'
THEN PO_DIST_GL_CODE_COMB.SEGMENT1 || PO_DIST_GL_CODE_COMB.SEGMENT2 || '_' || NVL(PO_DIST_GL_CODE_COMB.SEGMENT6,'000')
WHEN DT_REQ_ALL.EMPMGMTCD IS NOT NULL AND
PO_DIST_GL_CODE_COMB.SEGMENT2 = '1000'
THEN DT_REQ_ALL.EMPMGMTCD
END =DB2.DB2_FDW_MGMT_V.MH_CHILD )Explain plan. sorry can't get the explain plan from sql. this is from toad.
Plan
SELECT STATEMENT ALL_ROWSCost: 53,932 Bytes: 2,607 Cardinality: 1
79 HASH UNIQUE Cost: 53,932 Bytes: 2,607 Cardinality: 1
78 NESTED LOOPS OUTER Cost: 53,931 Bytes: 2,607 Cardinality: 1
75 NESTED LOOPS OUTER Cost: 53,928 Bytes: 2,560 Cardinality: 1
72 NESTED LOOPS Cost: 53,902 Bytes: 2,552 Cardinality: 1
69 NESTED LOOPS OUTER Cost: 53,900 Bytes: 2,533 Cardinality: 1
66 NESTED LOOPS OUTER Cost: 53,898 Bytes: 2,521 Cardinality: 1
63 HASH JOIN OUTER Cost: 53,896 Bytes: 2,509 Cardinality: 1
40 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_DISTRIBUTIONS_ALL Cost: 3 Bytes: 26 Cardinality: 1
39 NESTED LOOPS Cost: 17,076 Bytes: 2,400 Cardinality: 1
37 NESTED LOOPS Cost: 17,073 Bytes: 2,374 Cardinality: 1
34 NESTED LOOPS Cost: 17,070 Bytes: 2,362 Cardinality: 1
31 NESTED LOOPS Cost: 17,066 Bytes: 2,347 Cardinality: 1
29 NESTED LOOPS Cost: 17,066 Bytes: 2,339 Cardinality: 1
26 NESTED LOOPS Cost: 17,065 Bytes: 2,312 Cardinality: 1
23 NESTED LOOPS Cost: 17,064 Bytes: 2,287 Cardinality: 1
20 NESTED LOOPS Cost: 17,062 Bytes: 2,261 Cardinality: 1
17 NESTED LOOPS Cost: 17,056 Bytes: 6,678 Cardinality: 3
15 HASH JOIN Cost: 17,056 Bytes: 6,663 Cardinality: 3
13 MERGE JOIN CARTESIAN Cost: 135 Bytes: 30,352 Cardinality: 14
5 VIEW VIEW DB2.DB2_FDW_MGMT_V Cost: 4 Bytes: 2,128 Cardinality: 1
4 SORT UNIQUE Cost: 4 Cardinality: 1
3 UNION-ALL
1 REMOTE REMOTE SERIAL_FROM_REMOTE PRDFDW.WORLD
2 FAST DUAL Cost: 3 Cardinality: 1
12 BUFFER SORT Cost: 135 Bytes: 560 Cardinality: 14
11 VIEW DB2. Cost: 131 Bytes: 560 Cardinality: 14
10 SORT UNIQUE Cost: 131 Bytes: 310 Cardinality: 14
9 UNION-ALL
7 TABLE ACCESS BY INDEX ROWID TABLE GL.GL_DAILY_RATES Cost: 65 Bytes: 270 Cardinality: 9
6 INDEX SKIP SCAN INDEX (UNIQUE) GL.GL_DAILY_RATES_U1 Cost: 64 Cardinality: 1
8 INDEX SKIP SCAN INDEX (UNIQUE) GL.GL_DAILY_RATES_U1 Cost: 64 Bytes: 4,368 Cardinality: 546
14 TABLE ACCESS FULL TABLE PO.PO_HEADERS_ALL Cost: 16,920 Bytes: 32,754 Cardinality: 618
16 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Bytes: 5 Cardinality: 1
19 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 2 Bytes: 35 Cardinality: 1
18 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 2
22 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 2 Bytes: 26 Cardinality: 1
21 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1
25 TABLE ACCESS BY INDEX ROWID TABLE GL.GL_SETS_OF_BOOKS Cost: 1 Bytes: 25 Cardinality: 1
24 INDEX UNIQUE SCAN INDEX (UNIQUE) GL.GL_SETS_OF_BOOKS_U2 Cost: 0 Cardinality: 1
28 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_VENDORS Cost: 1 Bytes: 27 Cardinality: 1
27 INDEX UNIQUE SCAN INDEX (UNIQUE) PO.PO_VENDORS_U1 Cost: 0 Cardinality: 1
30 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 8 Cardinality: 1
33 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_LINES_ALL Cost: 4 Bytes: 60 Cardinality: 4
32 INDEX RANGE SCAN INDEX (UNIQUE) PO.PO_LINES_U2 Cost: 2 Cardinality: 4
36 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_LINE_LOCATIONS_ALL Cost: 3 Bytes: 12 Cardinality: 1
35 INDEX RANGE SCAN INDEX PO.PO_LINE_LOCATIONS_N1 Cost: 2 Cardinality: 1
38 INDEX RANGE SCAN INDEX PO.PO_DISTRIBUTIONS_N1 Cost: 2 Cardinality: 1
62 VIEW DB2. Cost: 36,819 Bytes: 1,090 Cardinality: 10
61 HASH UNIQUE Cost: 36,819 Bytes: 2,580 Cardinality: 10
60 NESTED LOOPS Cost: 36,818 Bytes: 2,580 Cardinality: 10
57 NESTED LOOPS Cost: 36,798 Bytes: 2,390 Cardinality: 10
54 NESTED LOOPS Cost: 36,768 Bytes: 2,220 Cardinality: 10
51 NESTED LOOPS Cost: 36,758 Bytes: 1,510 Cardinality: 10
48 NESTED LOOPS Cost: 36,747 Bytes: 1,050 Cardinality: 10
45 HASH JOIN Cost: 36,737 Bytes: 960 Cardinality: 10
43 HASH JOIN Cost: 34,602 Bytes: 230,340 Cardinality: 3,490
41 TABLE ACCESS FULL TABLE HR.PER_ALL_PEOPLE_F Cost: 1,284 Bytes: 1,848,420 Cardinality: 44,010
42 TABLE ACCESS FULL TABLE PO.PO_REQUISITION_LINES_ALL Cost: 31,802 Bytes: 18,340,080 Cardinality: 764,170
44 TABLE ACCESS FULL TABLE HR.PER_ALL_ASSIGNMENTS_F Cost: 2,134 Bytes: 822,540 Cardinality: 27,418
47 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 1 Bytes: 9 Cardinality: 1
46 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Cardinality: 1
50 TABLE ACCESS BY INDEX ROWID TABLE HR.PAY_COST_ALLOCATION_KEYFLEX Cost: 1 Bytes: 46 Cardinality: 1
49 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.PAY_COST_ALLOCATION_KEYFLE_PK Cost: 0 Cardinality: 1
53 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_REQUISITION_HEADERS_ALL Cost: 1 Bytes: 71 Cardinality: 1
52 INDEX UNIQUE SCAN INDEX (UNIQUE) PO.PO_REQUISITION_HEADERS_U1 Cost: 0 Cardinality: 1
56 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_REQ_DISTRIBUTIONS_ALL Cost: 3 Bytes: 17 Cardinality: 1
55 INDEX RANGE SCAN INDEX PO.PO_REQ_DISTRIBUTIONS_N1 Cost: 2 Cardinality: 1
59 TABLE ACCESS BY INDEX ROWID TABLE GL.GL_CODE_COMBINATIONS Cost: 2 Bytes: 19 Cardinality: 1
58 INDEX UNIQUE SCAN INDEX (UNIQUE) GL.GL_CODE_COMBINATIONS_U1 Cost: 1 Cardinality: 1
65 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_REQ_DISTRIBUTIONS_ALL Cost: 2 Bytes: 12 Cardinality: 1
64 INDEX UNIQUE SCAN INDEX (UNIQUE) PO.PO_REQ_DISTRIBUTIONS_U1 Cost: 1 Cardinality: 1
68 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_REQUISITION_LINES_ALL Cost: 2 Bytes: 12 Cardinality: 1
67 INDEX UNIQUE SCAN INDEX (UNIQUE) PO.PO_REQUISITION_LINES_U1 Cost: 1 Cardinality: 1
71 TABLE ACCESS BY INDEX ROWID TABLE GL.GL_CODE_COMBINATIONS Cost: 2 Bytes: 19 Cardinality: 1
70 INDEX UNIQUE SCAN INDEX (UNIQUE) GL.GL_CODE_COMBINATIONS_U1 Cost: 1 Cardinality: 1
74 TABLE ACCESS BY INDEX ROWID TABLE AP.AP_INVOICE_DISTRIBUTIONS_ALL Cost: 26 Bytes: 16 Cardinality: 2
73 INDEX RANGE SCAN INDEX AP.AP_INVOICE_DISTRIBUTIONS_N7 Cost: 2 Cardinality: 37
77 TABLE ACCESS BY INDEX ROWID TABLE AP.AP_INVOICES_ALL Cost: 3 Bytes: 47 Cardinality: 1
76 INDEX RANGE SCAN INDEX (UNIQUE) AP.AP_INVOICES_U1 Cost: 2 Cardinality: 1 ThanksForming a new table "new_table" with 3 tables which particiapate in CASE statement logic.
with DT_REQ_ALL as
SELECT DISTINCT
PO_RDA.DISTRIBUTION_ID,
PO_RLA.requisition_line_id,
PO_RHA.DESCRIPTION PO_Descr,
PO_RHA.NOTE_TO_AUTHORIZER PO_Justification,
Req_Emp.FULL_NAME,
GL_CC.SEGMENT1 Req_Company_Code,
GL_CC.SEGMENT2 Req_Cost_Center,
Req_Emp_CC.SEGMENT1 Emp_Company_Code,
Req_Emp_CC.SEGMENT2 Emp_Cost_Center,
(Case
When GL_CC.SEGMENT2 8000
Then TRUNC(GL_CC.SEGMENT1) || TRUNC(GL_CC.SEGMENT2) || '_' || NVL(GL_CC.SEGMENT6,'000')
Else TRUNC(Req_Emp_CC.SEGMENT1) || TRUNC(Req_Emp_CC.SEGMENT2) || '_' || NVL(Req_Emp_CC.SEGMENT6,'000')
End) EmpMgmtCD
FROM
PO.po_requisition_lines_all PO_rla,
PO.po_requisition_headers_all PO_rha,
PO.PO_REQ_DISTRIBUTIONS_ALL po_RDA,
GL.GL_CODE_COMBINATIONS gl_cc,
HR.PER_ALL_PEOPLE_F Req_Emp,
HR.PER_ALL_ASSIGNMENTS_F Req_Emp_Assign,
HR.hr_all_organization_units Req_Emp_Org,
HR.pay_cost_allocation_keyflex Req_Emp_CC
WHERE
PO_RDA.CODE_COMBINATION_ID = GL_CC.CODE_COMBINATION_ID and
PO_RLA.REQUISITION_LINE_ID = PO_RDA.REQUISITION_LINE_ID AND
PO_RLA.to_person_id = Req_Emp.PERSON_ID AND
PO_RLA.REQUISITION_HEADER_ID = PO_RHA.REQUISITION_HEADER_ID AND
(trunc(PO_rla.CREATION_DATE) between Req_Emp.effective_start_date and Req_Emp.effective_end_date OR
Req_Emp.effective_start_date IS NULL) AND
Req_Emp.PERSON_ID = Req_Emp_Assign.PERSON_ID AND
Req_Emp_Assign.organization_id = Req_Emp_Org.organization_id AND
(trunc(PO_rla.CREATION_DATE) between Req_Emp_Assign.effective_start_date and Req_Emp_Assign.effective_end_date OR
Req_Emp_Assign.effective_start_date IS NULL) AND
Req_Emp_Assign.primary_flag = 'Y' AND
Req_Emp_Assign.assignment_type = 'E' AND
Req_Emp_Org.cost_allocation_keyflex_id = Req_Emp_CC.cost_allocation_keyflex_id
SELECT DISTINCT
D.DB2_FDW_MGMT_V.RC_PARENT,
DT_REQ_ALL.FULL_NAME,
DT_REQ_ALL.EMP_COMPANY_CODE,
DT_REQ_ALL.EMP_COST_CENTER,
PO.PO_VENDORS.VENDOR_NAME,
PO_PO_HEADERS_ALL2.SEGMENT1,
PO_PO_HEADERS_ALL2.CREATION_DATE,
PO_DIST_GL_CODE_COMB.SEGMENT1,
PO_DIST_GL_CODE_COMB.SEGMENT2,
PO_PO_HEADERS_ALL2.CURRENCY_CODE,
PO_INV_DIST_ALL.INVOICE_NUM,
PO_INV_DIST_ALL.INVOICE_DATE,
(PO_INV_DIST_ALL.INVOICE_AMOUNT* PO_Rates_GL_DR.CONVERSION_RATE),
(NVL(to_number(PO_DIST_ALL.AMOUNT_BILLED),0) * PO_Rates_GL_DR.CONVERSION_RATE),
PO_LINES_LOC.LINE_NUM,
GL.GL_SETS_OF_BOOKS.NAME,
CASE
WHEN TRUNC(PO_PO_HEADERS_ALL2.CREATION_DATE) > PO_INV_DIST_ALL.INVOICE_DATE
THEN 1
ELSE 0
END ,
PO.PO_REQUISITION_LINES_ALL.LINE_LOCATION_ID,
TRUNC(PO_PO_HEADERS_ALL2.CREATION_DATE,'WW') + 8 WEEK_Ending
FROM
( SELECT * FROM
DB2.DB2_FDW_MGMT_V,
GL.GL_CODE_COMBINATIONS PO_DIST_GL_CODE_COMB,
DT_REQ_ALL
WHERE
DB2.DB2_FDW_MGMT_V.RC_PARENT In ( 'Unavailable','Corp','Commercial' )
AND
CASE
WHEN PO_DIST_GL_CODE_COMB.SEGMENT2 <> '1000'
THEN PO_DIST_GL_CODE_COMB.SEGMENT1 || PO_DIST_GL_CODE_COMB.SEGMENT2 || '_' || NVL(PO_DIST_GL_CODE_COMB.SEGMENT6,'000')
WHEN DT_REQ_ALL.EMPMGMTCD IS NOT NULL AND
PO_DIST_GL_CODE_COMB.SEGMENT2 = '1000'
THEN DT_REQ_ALL.EMPMGMTCD
END =DB2.DB2_FDW_MGMT_V.MH_CHILD
) new_table,
PO.PO_VENDORS,
PO.PO_HEADERS_ALL PO_PO_HEADERS_ALL2,
AP.AP_INVOICES_ALL PO_INV_DIST_ALL,
PO.PO_DISTRIBUTIONS_ALL PO_DIST_ALL,
PO.PO_LINES_ALL PO_LINES_LOC,
GL.GL_SETS_OF_BOOKS,
PO.PO_REQUISITION_LINES_ALL,
PO.PO_LINE_LOCATIONS_ALL,
AP.AP_INVOICE_DISTRIBUTIONS_ALL PO_DIST_INV_DIST_ALL,
APPS.HR_OPERATING_UNITS,
PO.PO_REQ_DISTRIBUTIONS_ALL,
SELECT
FROM_CURRENCY,
TO_CURRENCY,
CONVERSION_DATE,
CONVERSION_RATE
FROM GL.GL_DAILY_RATES
UNION
SELECT Distinct
'USD',
'USD',
CONVERSION_DATE,
1
FROM GL.GL_DAILY_RATES
) PO_Rates_GL_DR
WHERE
( PO_DIST_GL_CODE_COMB.CODE_COMBINATION_ID=PO_DIST_ALL.CODE_COMBINATION_ID )
AND ( PO_DIST_ALL.LINE_LOCATION_ID=PO.PO_LINE_LOCATIONS_ALL.LINE_LOCATION_ID )
AND ( PO_PO_HEADERS_ALL2.VENDOR_ID=PO.PO_VENDORS.VENDOR_ID )
AND ( PO_PO_HEADERS_ALL2.ORG_ID=APPS.HR_OPERATING_UNITS.ORGANIZATION_ID )
AND ( GL.GL_SETS_OF_BOOKS.SET_OF_BOOKS_ID=APPS.HR_OPERATING_UNITS.SET_OF_BOOKS_ID )
AND ( PO_PO_HEADERS_ALL2.CURRENCY_CODE=PO_Rates_GL_DR.FROM_CURRENCY )
AND ( trunc(PO_PO_HEADERS_ALL2.CREATION_DATE)=PO_Rates_GL_DR.CONVERSION_DATE )
AND ( PO_DIST_ALL.REQ_DISTRIBUTION_ID=PO.PO_REQ_DISTRIBUTIONS_ALL.DISTRIBUTION_ID(+) )
AND ( PO.PO_REQ_DISTRIBUTIONS_ALL.REQUISITION_LINE_ID=PO.PO_REQUISITION_LINES_ALL.REQUISITION_LINE_ID(+) )
AND ( PO_LINES_LOC.PO_HEADER_ID=PO_PO_HEADERS_ALL2.PO_HEADER_ID )
AND ( PO.PO_LINE_LOCATIONS_ALL.PO_LINE_ID=PO_LINES_LOC.PO_LINE_ID )
AND ( PO_DIST_ALL.REQ_DISTRIBUTION_ID=DT_REQ_ALL.DISTRIBUTION_ID(+) )
AND ( PO_DIST_ALL.PO_DISTRIBUTION_ID=PO_DIST_INV_DIST_ALL.PO_DISTRIBUTION_ID(+) )
AND ( PO_INV_DIST_ALL.INVOICE_ID(+)=PO_DIST_INV_DIST_ALL.INVOICE_ID )
AND ( PO_INV_DIST_ALL.SOURCE(+) 'XML GATEWAY' )
AND
( NVL(PO_PO_HEADERS_ALL2.CANCEL_FLAG,'N') 'Y' )
AND
( NVL(PO_PO_HEADERS_ALL2.CLOSED_CODE, 'OPEN') 'FINALLY CLOSED' )
AND
( NVL(PO_PO_HEADERS_ALL2.AUTHORIZATION_STATUS,'IN PROCESS') 'REJECTED' )
AND
( TRUNC(PO_PO_HEADERS_ALL2.CREATION_DATE) BETWEEN TO_DATE('01-jan-2011') AND TO_DATE('04-jan-2011') )
AND
PO_Rates_GL_DR.TO_CURRENCY = 'USD'
-
SQL query slow with call to function
I have a SQL query that will return in less than a second or two with a function in-line selected in the "from" clause of the statement. As soon as I select that returned value in the SQL statement, the statement takes from anywhere from 2 to 5 minutes to return. Here is a simplified sample from the statement:
This statement returns in a second or 2.
select A.pk_id
from stu_schedule A, stu_school B, stu_year C, school_year D,
(select calc_ytd_class_abs2(Z.PK_ID,'U') ytd_unx
from stu_schedule Z) II
where B.pk_id = A.fk_stu_school
and C.pk_id = B.fk_stu_year
and D.pk_id = C.year
and D.school_year = '2011';
if I add this function call in, the statement runs extremely poor.
select A.pk_id,
II.ytd_unx
from stu_schedule A, stu_school B, stu_year C, school_year D,
(select calc_ytd_class_abs2(Z.PK_ID,'U') ytd_unx
from stu_schedule Z) II
where B.pk_id = A.fk_stu_school
and C.pk_id = B.fk_stu_year
and D.pk_id = C.year
and D.school_year = '2011';
Here is the function that is called:
create or replace FUNCTION calc_ytd_class_abs2 (p_fk_stu_schedule in varchar2,
p_legality in varchar2) return number IS
l_days_absent number := 0;
CURSOR get_class_abs IS
select (select nvl(max(D.days_absent),'0')
from cut_code D
where D.pk_id = C.fk_cut_code
and (D.legality = p_legality
or p_legality = '%')) days_absent
from stu_schedule_detail B, stu_class_attendance C
where B.fk_stu_schedule = p_fk_stu_schedule
and C.fk_stu_schedule_detail = B.pk_id;
BEGIN
FOR x in get_class_abs LOOP
l_days_absent := l_days_absent + x.days_absent;
END LOOP;
return (l_days_absent);
END calc_ytd_class_abs2;Query returns anywhere from 6000 to 32000 rows. For each of those rows a parameter is passed in to 4 different functions to get ytd totals. When I call the functions in the in-line view but do not select from them in the main SQL, the report (oh, this is Application Express 4.0 interactive reports, just an FYI) runs fast. The report comes back in a few seconds. But when I select from the in-line view to display those ytd totals, the report runs extremely slow. I know there are the articles about context switching and how mixing SQL with PL/SQL performs poorly. So I tried a pipeline table function where the function for the ytd totals populate the columns of the pipeline table and I select from the pipeline table in the SQL query in the interactive report. That seemed to perform a little worse from what I can tell.
Thanks for any help you can offer. -
Sql query slow while using poc *C, OCI
Sql query is taking long time while using fetching records from RAC using Pro *C, OCI. Same query working fine while using JDBC connection.what could be the issue.Please help
Thanks,
SamPro*C is not part of Oracle Solaris Studio (formerly Sun Studio). Studio has no special support for database programming. You are more likely to get a helpful answer in a database programming forum. Start here:
https://forums.oracle.com/forums/category.jspa?categoryID=18 -
MS SQL query slow using view column as criteria
HI,
I am experiencing a very frustrate problem. I have 2 tables, and create a view
to union these 2 tables, when do a select on this view using the column of the
view as criteria is took more 1 minutes, but the query runs fine in Qurey Analyzer.
Anybody has the same experience? is this the problem with jdbc?I searched http://e-docs.bea.com/wls/docs70/index.html, also searched the documentation
for wls6.1, wls5.1. As you pointed I searched support site, they are all the customer
case, it's not formal documentation.
Joe Weinstein <[email protected]> wrote:
>
>
jen wrote:
Thanks. but I search on the table is fine (the same column). is thereany db setting
could be tuned? so the view is the problem? No, it's a client decision/issue. If you defined your tables to have
nvarchar columns
the jdbc driver's parameter values would be fine as-is.
I searched "useVarChars" on whole
site and can't find anything.Which site? This is a property of the weblogic.jdbc.mssqlserver4.Driver.
I just went to www.bea.com/support and entered useVarChars in the Ask
BEA
question panel and got hits...
Joe
Joe Weinstein <[email protected]> wrote:
Jen wrote:
Sorry it's my bad. I am testing on wls81, but the problems is on wls70,so they
are using different drivers.
You are the magic man. It worked on wls81 now. I am sure it will curethe problem
on wls70. Is there any documentation on this? Why it is not a problemon some
databse server? ThanksSure. The issue has to do with the MS client-DBMS protocol having evolved
from
an 8-bit (7-bit really) character representation. Now it has a newer
16-bit
way, to transfer NVARCHAR data. Java characters are all 16-bit, so
by default
a JDBC driver will send Java parameters over as NVARCHAR data. This
is
crucial
for Japanese data etc. However, once simple ASCII data is transformed
to an
NVARCHAR format, the DBMS can't directly compare it to varchar data,
or use it
in index searches. The DBMS has to convert the VARCHAR data to NVARCHAR,
but it
can't guarantee that the converted data will retain the same ordering
as the index,
so the DBMS has to do a table scan!
The properties I suggested are each driver's way of allowing you
to say "I'm
a simple American ;) I am using simple varchar data so please sendmy
java
strings that way.". This allows the DBMS to use your varchar indexes
in queries.
Joe Weinstein at BEA
Joe Weinstein <[email protected]> wrote:
Jen wrote:
It doesn't cure the problem. Here is my pool
<JDBCConnectionPool DriverName="weblogic.jdbc.sqlserver.SQLServerDriver"Name="test_pool"
Password="{3DES}fKSovViFe5kHzl/vTs0LVQ==" Properties="user=user;PortNumber=1543;useVarChars=true;ServerName=194.20.2.10;DatabaseName=devDB"
Targets="admin" TestTableName="SQL SELECT COUNT(*) FROM sysobjects"URL="jdbc:bea:sqlserver://194.20.2.10:1543"/>
Strange is some database is fine.Oh, sorry. I thought it was the older weblogic driver. Change the
useVarChars=true to sendStringParametersAsUnicode=false
Let me know... Also, I suggest changing the TestTableName to "SQL
select
1".
For MS, that will be much more efficient than involving a full count
of sysobjects!
Joe
Joe Weinstein <[email protected]> wrote:
Jen wrote:
You are right. Tadaa! Am I Kreskin, or what? ;) Here's what I recommend:
In your pool definition, for this driver add a driver property:
useVarChars=true
and let me know if it's all better.
Joe
I am using weblogic jdbc driver weblogic.jdbc.mssqlserver4.Driver.
here is the code:
getData(Connection connection, String stmt, ArrayList arguments)
PreparedStatement pStatement=null;>>>>>>>> ResultSet resultSet=null;>>>>>>>> try {>>>>>>>> pStatement = connection.prepareStatement(stmt);>>>>>>>> for (int i = 1; i <= arguments.size(); i++) {>>>>>>>> pStatement.setString(i, (String) arguments.get(i-1));>>>>>>>> resultSet = pStatement.executeQuery(); //this statement takesmore than 1
min.
Joe Weinstein <[email protected]> wrote:
Jen wrote:
HI,
I am experiencing a very frustrate problem. I have 2 tables,
and
create
a view
to union these 2 tables, when do a select on this view using
the
column
of the
view as criteria is took more 1 minutes, but the query runs
fine
in
Qurey Analyzer.
Anybody has the same experience? is this the problem with jdbc?
I have suspicions... Show me the jdbc code. I'm guessing it's
a
PreparedStatement,
and you send the search criterion column value as a parameter
you
set
with a
setString().... Let me know... (also let me know which jdbc driveryou're
using).
Joe -
Query slow in user schema but fast in sys schema
Hi,
DB :10.2.
OS :Aix
Tool : Toad
We executed a query which fast(20 seconds) in sys schema.
But it's taking slow in user schema(it is taken 10 minutes).
Yesterday we gathered dictionary stats also.
Any suggestions.
Thanks & Regards,
VNYou're querying a bunch of USER_<<x>> data dictionary views. Since those views show the objects owned by the current user, the script you generate will be completely different depending on the identity of the current user and the set of objects owned by the current user. If you create a new user and run this script as the new user, it will be even faster because USER_TABLES, USER_SEGMENTS, USER_INDEXES, etc. will all be empty.
I don't understand why you would issue a MOVE on a table without specifying a new tablespace-- that seems like a pointless exercise. And I would seriously question the architect that wants to use ANALYZE to gather statistics rather than using DBMS_STATS.
Justin -
Sql query slow from application but executes in 1 min in Toad
Hello,
When I execute a big select query from DB itself , it gives results in a min.
But when called from .Net application it takes 10 mins to execute.
But after trying to excute no of times, it suddenly works faster sometimes.Hello,
When I execute a big select query from DB itself , it gives results in a min.
But when called from .Net application it takes 10 mins to execute.
But after trying to excute no of times, it suddenly works faster sometimes. -
Performance Problem with SQL Query
Hi
I have a SQL Query (say, SSS) which runs quite fast when I run it from TOAD.
But when the same query is being used as
INSERT INTO <table> VALUES <SSS>;
It is taking hours to complete.
The Original Query(OSQ) was changed to this SQL query(SSS) for Performance improvement.
The Cost has also improved quite a lot from OSQ to SSS. But when SSS runs from inside a procedure it is taking the same long hours as OSQ used to take.
Please help ASAP as it needs to get fixed.
Thanks
ArnabSELECT SRM.ID PROJECT_ID,
SRM.UNIQUE_NAME PROJECT_CODE,
ODFP.GS_FINANCE_PROJ_CODE,
ODFP.GS_PRODUCT_CODE,
ODFP.GS_CUSTOMER,
ODFP.GS_LEGAL_ENT_REF,
ODF_PRJ_TYPE.NAME GS_PROJ_TYPE,
ODF_SRC_SYS.NAME GS_SOURCE_SYSTEM,
RESM.FIRST_NAME||' '||RESM.LAST_NAME GS_PROJECT_MANAGER,
ODFP.GS_LEG_PROJ_NUM,
ODFP.GS_SUPP_DOC ,
ODFP.GS_REQUEST_ID ,
ODFP.GS_CONTRACT ,
ODFP.GS_SIEBEL_REF,
DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg)LAB_BDGT,
DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)NLI_BDGT,
(DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg))+(DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)) sum_lab_nonlab_budg,
frct.LABOUR,
frct.NON_LABOUR,
frct.LABOUR+frct.NON_LABOUR FORCAST_TOT_SUM,
gfr.code GFR_CODE,
odfp.gs_rev_recognition,
rev_rec.NAME gs_rev_recognition,
DECODE(odfp.gs_prevent_reqtxn,1,'YES','0','NO','NO'),
GS_PROGTYPE.NAME,
COMM_APPR.UNIQUE_NAME COMM_APPROVER_EIN,
COMM_APPR.FIRST_NAME||' '||COMM_APPR.LAST_NAME COMM_APPROVER_NAME,
PR_APPR.UNIQUE_NAME PR_APPROVER_EIN,
PR_APPR.FIRST_NAME||' '||PR_APPR.LAST_NAME PR_APPROVER_NAME,
ODFP.GS_BILL_BUD,
frct.FRCST_REVENUE TOTAL_FRC_REVENUE,
actuals.LABOUR_ACTUALS,
actuals.NL_ACTUALS,
-- get_wip_totalcost(prjp.prid,'L') LABOUR_ACTUALS,
-- get_wip_totalcost(prjp.prid,'M') NL_ACTUALS,
ODFP.GS_ASS_PRODUCT_CODE,
PROJ_TEMPLATE.ID GS_PROJ_TEMPLATE_ID,
PROJ_TEMPLATE.UNIQUE_NAME GS_PROJ_TEMPLATE_CODE,
PROJ_TEMPLATE.name GS_PROJ_TEMPLATE_NAME,
DECODE( NVL(ODFP.GS_FIN_TEMPLATE,0) ,0,'NO',1,'YES') GS_FIN_TEMPLATE,
ODF_PRJ_TYPE.LOOKUP_CODE GS_PROJ_TYPE
FROM PROJECTS SRM,
J_PROJECTS PRJP,
A_PROJECT ODFP,
RESOURCES RESM,
s_gfr gfr,
RESOURCES PROJ_ACCT,
RESOURCES COMM_APPR,
RESOURCES PR_APPR,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROJECT_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_PRJ_TYPE,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_SOURCE_SYSTEM'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_SRC_SYS,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROG_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS')GS_PROGTYPE,
(SELECT odf_parent_id
,SUM(gs_lab_budg) lab_budg
,SUM(gs_nl_budg) nli_budg
FROM T_CHANGES
WHERE gs_status='APPR'
GROUP BY odf_parent_id) budg,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_REV_RECOGNITION'
AND LOOKUP.ID = CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') rev_rec,
(SELECT FRCP1.project_id,
NVL(SUM(CASE WHEN srmr.resource_type=0 THEN for_val.cost ELSE NULL END),0) AS LABOUR,
NVL(SUM(CASE WHEN srmr.resource_type <> 0 THEN for_val.cost ELSE NULL END),0) AS NON_LABOUR,
NVL(SUM(for_val.revenue),0) AS FRCST_REVENUE
FROM T_PROPERTIES FRCP1,
T_DETAILS FOR_DET,
RESOURCES SRMR,
T_VALUES FOR_VAL
WHERE (FRCP1.project_id, revision) IN (SELECT project_id, MAX(revision)
FROM T_PROPERTIES FRCP
WHERE FRCP.status=2
AND FRCP.PERIOD_TYPE='SEMI_MONTHLY'
GROUP BY project_id)
AND FRCP1.PERIOD_TYPE='SEMI_MONTHLY'
AND FOR_DET.forecast_id=frcp1.id
AND SRMR.id(+)=FOR_DET.detail_id
AND FOR_VAL.currency_type='BILLING'
AND FOR_VAL.forecast_details_id=FOR_DET.ID
GROUP BY FRCP1.project_id) frct,
(SELECT srmp.id
,NVL(SUM(CASE WHEN wip.transtype='L' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS LABOUR_ACTUALS
,NVL(SUM(CASE WHEN wip.transtype='M' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS NL_ACTUALS
FROM A_WIP WIP
,om_periods biz
,P_VALUES WIPVAL
,PROJECTS SRMP
,A_PROJECT ODF
WHERE biz.period_type ='SEMI_MONTHLY'
AND TRUNC(wip.TRANSDATE) BETWEEN biz.start_date AND biz.end_date
AND WIP.TRANSNO=WIPVAL.TRANSNO
AND WIPVAL.CURRENCY_TYPE='BILLING'
AND SRMP.UNIQUE_NAME=WIP.PROJECT_CODE
AND SRMP.ID=ODF.ID
AND UPPER(ODF.partition_code)='GLOBAL'
AND UPPER(WIP.external_id) <> 'SPREADSHEET'
GROUP BY srmp.id) actuals,
RESOURCES BUD_HOLDER,
PROJECTS PROJ_TEMPLATE
WHERE SRM.ID = PRJP.PRID
AND ODFP.ID=PRJP.PRID
AND ODFP.PARTITION_CODE='GLOBAL'
AND RESM.id(+)=prjp.manager_id
AND ODFP.GS_PROJECT_TYPE = ODF_PRJ_TYPE.LOOKUP_CODE(+)
AND ODFP.GS_SOURCE_SYSTEM = ODF_SRC_SYS.LOOKUP_CODE(+)
AND ODFP.GS_prog_type = GS_PROGTYPE.LOOKUP_CODE(+)
AND budg.odf_parent_id(+)=SRM.ID
AND frct.project_id(+) = prjp.prid
AND ODFP.gs_risk_gfr=gfr.code(+)
AND ODFP.GS_REV_RECOGNITION=rev_rec.LOOKUP_CODE(+)
AND ODFP.GS_PROJ_ACCT = PROJ_ACCT.ID(+)
AND ODFP.GS_COMM_APPR = COMM_APPR.ID(+)
AND ODFP.GS_PR_APPR = PR_APPR.ID(+)
AND actuals.id(+) = prjp.prid -- Arnab
AND ODFP.GS_BUDGET_HOLDER=BUD_HOLDER.ID(+)
AND ODFP.GS_TEMPLATE_USED=PROJ_TEMPLATE.ID(+)
The above is OSQ with cost 45000. ... takes 1-1.5 hours through Toad
SELECT SRM.ID PROJECT_ID,
SRM.UNIQUE_NAME PROJECT_CODE,
ODFP.GS_FINANCE_PROJ_CODE,
ODFP.GS_PRODUCT_CODE,
ODFP.GS_CUSTOMER,
ODFP.GS_LEGAL_ENT_REF,
ODF_PRJ_TYPE.NAME GS_PROJ_TYPE,
ODF_SRC_SYS.NAME GS_SOURCE_SYSTEM,
RESM.FIRST_NAME||' '||RESM.LAST_NAME GS_PROJECT_MANAGER,
ODFP.GS_LEG_PROJ_NUM,
ODFP.GS_SUPP_DOC ,
ODFP.GS_REQUEST_ID ,
ODFP.GS_CONTRACT ,
ODFP.GS_SIEBEL_REF,
DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg)LAB_BDGT,
DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)NLI_BDGT,
(DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg))+(DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)) sum_lab_nonlab_budg,
frct.LABOUR,
frct.NON_LABOUR,
frct.LABOUR+frct.NON_LABOUR FORCAST_TOT_SUM,
gfr.code GFR_CODE,
odfp.gs_rev_recognition,
rev_rec.NAME gs_rev_recognition,
DECODE(odfp.gs_prevent_reqtxn,1,'YES','0','NO','NO'),
GS_PROGTYPE.NAME,
COMM_APPR.UNIQUE_NAME COMM_APPROVER_EIN,
COMM_APPR.FIRST_NAME||' '||COMM_APPR.LAST_NAME COMM_APPROVER_NAME,
PR_APPR.UNIQUE_NAME PR_APPROVER_EIN,
PR_APPR.FIRST_NAME||' '||PR_APPR.LAST_NAME PR_APPROVER_NAME,
ODFP.GS_BILL_BUD,
frct.FRCST_REVENUE TOTAL_FRC_REVENUE,
-- actuals.LABOUR_ACTUALS, -- Arnab
-- actuals.NL_ACTUALS, -- Arnab
get_wip_totalcost(prjp.prid,'L') LABOUR_ACTUALS, -- Arnab
get_wip_totalcost(prjp.prid,'M') NL_ACTUALS, -- Arnab
ODFP.GS_ASS_PRODUCT_CODE,
PROJ_TEMPLATE.ID GS_PROJ_TEMPLATE_ID,
PROJ_TEMPLATE.UNIQUE_NAME GS_PROJ_TEMPLATE_CODE,
PROJ_TEMPLATE.name GS_PROJ_TEMPLATE_NAME,
DECODE( NVL(ODFP.GS_FIN_TEMPLATE,0) ,0,'NO',1,'YES') GS_FIN_TEMPLATE,
ODF_PRJ_TYPE.LOOKUP_CODE GS_PROJ_TYPE
FROM PROJECTS SRM,
J_PROJECTS PRJP,
A_PROJECT ODFP,
RESOURCES RESM,
s_gfr gfr,
RESOURCES PROJ_ACCT,
RESOURCES COMM_APPR,
RESOURCES PR_APPR,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROJECT_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_PRJ_TYPE,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_SOURCE_SYSTEM'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_SRC_SYS,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROG_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS')GS_PROGTYPE,
(SELECT odf_parent_id
,SUM(gs_lab_budg) lab_budg
,SUM(gs_nl_budg) nli_budg
FROM T_CHANGES
WHERE gs_status='APPR'
GROUP BY odf_parent_id) budg,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_REV_RECOGNITION'
AND LOOKUP.ID = CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') rev_rec,
(SELECT FRCP1.project_id,
NVL(SUM(CASE WHEN srmr.resource_type=0 THEN for_val.cost ELSE NULL END),0) AS LABOUR,
NVL(SUM(CASE WHEN srmr.resource_type <> 0 THEN for_val.cost ELSE NULL END),0) AS NON_LABOUR,
NVL(SUM(for_val.revenue),0) AS FRCST_REVENUE
FROM T_PROPERTIES FRCP1,
T_DETAILS FOR_DET,
RESOURCES SRMR,
T_VALUES FOR_VAL
WHERE (FRCP1.project_id, revision) IN (SELECT project_id, MAX(revision)
FROM T_PROPERTIES FRCP
WHERE FRCP.status=2
AND FRCP.PERIOD_TYPE='SEMI_MONTHLY'
GROUP BY project_id)
AND FRCP1.PERIOD_TYPE='SEMI_MONTHLY'
AND FOR_DET.forecast_id=frcp1.id
AND SRMR.id(+)=FOR_DET.detail_id
AND FOR_VAL.currency_type='BILLING'
AND FOR_VAL.forecast_details_id=FOR_DET.ID
GROUP BY FRCP1.project_id) frct,
/* (SELECT srmp.id
,NVL(SUM(CASE WHEN wip.transtype='L' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS LABOUR_ACTUALS
,NVL(SUM(CASE WHEN wip.transtype='M' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS NL_ACTUALS
FROM A_WIP WIP
,om_periods biz
,P_VALUES WIPVAL
,PROJECTS SRMP
,A_PROJECT ODF
WHERE biz.period_type ='SEMI_MONTHLY'
AND TRUNC(wip.TRANSDATE) BETWEEN biz.start_date AND biz.end_date
AND WIP.TRANSNO=WIPVAL.TRANSNO
AND WIPVAL.CURRENCY_TYPE='BILLING'
AND SRMP.UNIQUE_NAME=WIP.PROJECT_CODE
AND SRMP.ID=ODF.ID
AND UPPER(ODF.partition_code)='GLOBAL'
AND UPPER(WIP.external_id) <> 'SPREADSHEET'
GROUP BY srmp.id) actuals, */ -- Arnab
RESOURCES BUD_HOLDER,
PROJECTS PROJ_TEMPLATE
WHERE SRM.ID = PRJP.PRID
AND ODFP.ID=PRJP.PRID
AND ODFP.PARTITION_CODE='GLOBAL'
AND RESM.id(+)=prjp.manager_id
AND ODFP.GS_PROJECT_TYPE = ODF_PRJ_TYPE.LOOKUP_CODE(+)
AND ODFP.GS_SOURCE_SYSTEM = ODF_SRC_SYS.LOOKUP_CODE(+)
AND ODFP.GS_prog_type = GS_PROGTYPE.LOOKUP_CODE(+)
AND budg.odf_parent_id(+)=SRM.ID
AND frct.project_id(+) = prjp.prid
AND ODFP.gs_risk_gfr=gfr.code(+)
AND ODFP.GS_REV_RECOGNITION=rev_rec.LOOKUP_CODE(+)
AND ODFP.GS_PROJ_ACCT = PROJ_ACCT.ID(+)
AND ODFP.GS_COMM_APPR = COMM_APPR.ID(+)
AND ODFP.GS_PR_APPR = PR_APPR.ID(+)
AND actuals.id(+) = prjp.prid Arnab
AND ODFP.GS_BUDGET_HOLDER=BUD_HOLDER.ID(+)
AND ODFP.GS_TEMPLATE_USED=PROJ_TEMPLATE.ID(+)
This one in SSS where "-- Arnab " are only changes .....
The cost of this 7000.....finishes in 1 - 1.5 min in Toad
This is used as INSERT INTO TABLE <Select Query> ... this was taking 1.5 Hours to run.
It was changed using BULK COLLECT - still its taking around 1.5 hours to run...
Thanks
Arnab -
Sql query extremely slow in the new linux environment , memory issues?
We just migrated to a new dev environment in Linux REDHAT5, and now the query is very slow, and I used the TOAD to run the query, it took like 700 msecond to finish, however from any server connection, the sql query takes hours to finish.
I checked toad monitor, it said need to increase db_buffer_cache and shared pool too small.
Also three red alert from toad is:
1. Library Cache get hit ratio: Dynamic or unsharable sql
2. Chained fetch ratio: PCT free too low for a table
3. parse to execute ratio: HIgh parse to execute ratio.
App team said it ran real quick in the old AIX system, however I ran it in old system, and monitored in the toad, it gave me all same 5 red alerts in old system, and it did provide query results a lot quicker though.
Here is the parameters in the old system (11gr1 on AIX):
SQL> show parameter target
NAME TYPE VALUE
archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 0
memory_target big integer 0
pga_aggregate_target big integer 278928K
sga_target big integer 0
SQL> show parameter shared
NAME TYPE VALUE
hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 31876710
shared_pool_size big integer 608M
shared_server_sessions integer
shared_servers integer 0
SQL> show parameter db_buffer
SQL> show parameter buffer
NAME TYPE VALUE
buffer_pool_keep string
buffer_pool_recycle string
db_block_buffers integer 0
log_buffer integer 2048000
use_indirect_data_buffers boolean FALSE
SQL>
In new 11gr2 Linux REDHAT parameter:
NAME TYPE VALUE
archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 2512M
memory_target big integer 2512M
parallel_servers_target integer 192
pga_aggregate_target big integer 0
sga_target big integer 1648M
SQL> show parameter shared
NAME TYPE VALUE
hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 28M
shared_pool_size big integer 0
shared_server_sessions integer
shared_servers integer 1
SQL> show parameter buffer
NAME TYPE VALUE
buffer_pool_keep string
buffer_pool_recycle string
db_block_buffers integer 0
log_buffer integer 18857984
use_indirect_data_buffers boolean FALSE
SQL>
Please help. Thanks in advance.Duplicate question. Originally posted in sql query slow in new redhat enviornment
Please post in just one forum. -
SQL query can be executed through TOAD but not through Discoverer
Hallo, everybody:
Got another problem. A SQL query can be executed through TOAD, but when I want to execute it by a worksheet of Discoverer Plus, it always shows there is no data.
PS: I copied this query from Discoverer Plus to TOAD, which means, this query is generated through the Discoverer. Does anybody know about how could it be?
Thank you.
GengHi,
If you are able to get data in TOAD with the same user credential as that of Discoverer Plus then it will implies an issue with Discoverer.
Else it is privilege issue , your TOAD user has select privilege to the base objects (tables/views etc) where as your Disoverer used does not.
Compare the privileges granted to these 2 users and you can narrow done to the issue .
Thanks,
Sutirtha -
Getting Zero Sized Reply error in report from SQL query
Hi,
I have a Report from SQL Query in Portal 3.0.9. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
ERROR
The requested URL could not be retrieved
While trying to retrieve the URL: <data suppressed>
The following error was encountered:
Zero Sized Reply
Squid did not receive any data for this request.
Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
Thanks,
LorenaHi,
I have a Report from SQL Query in Portal 3.0.9. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
ERROR
The requested URL could not be retrieved
While trying to retrieve the URL: <data suppressed>
The following error was encountered:
Zero Sized Reply
Squid did not receive any data for this request.
Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
Thanks,
Lorena
Maybe you are looking for
-
Workitem attachment missing in mail Outlook/Lotus
When an email is generated from a particular workflow. I get the following message in my outlook inbox Subject :Please release purchase requisition 0013001141 Body : Work item in R/3 System: DEV Please log on to the R/3 System and look in your inbox
-
Completely clearing out a child?
I've having a problem when I am removing a child. There is an area where you can choose a button to click(there are multiple buttons here). Once you click a button it loads workss_mc and you can go back from there and workss_mc is being removed the
-
Mobile data network loss but with signal bars
i keep trying to send text messages or make phone calls but they keep failing and returning a message saying unable to connect to data network, i thought that only applied for internet services? its saying i have atleast 3 or 4 bars of signal when i
-
Even with photo stream on photos are not showing up on my iPad. I'm running on OS 5.1
-
Non riesco ad installare iTunes 11.1.4 su windows 7
Non riesco ad installare iTunes 11.1.4 su windows 7 e su winduws XP Su tutti e due mi da il messaggio di errore come da screen shot allegato Chiedo come fare per proseguire Grazie e saluti