SQL query / binding issues within dreamweaver
Not sure if anyone has had this problem, but its getting
annoying.. when i
execute this within SQL it returns all the values requested.
If i execute it
within dreamweaver to show me what results i will get back it
works there..
but after i bind the fields to my page and view it only some
or all my
fields do not display any data... but if i play around with
the order of my
select statement below i can get some fields to display and
other
disappear... and i dont ever touch my webpage again...
Can anyone shed some light on this issue? Or is there a
better way to
display my results so that what i get back with my query will
always
display....
here is my stored procedure that im calling
SET NOCOUNT ON;
SELECT
c.cfname,c.clname,c.cid,h.termcode,h.hiredate,h.lastdate,h.cdateh,
h.cdatet,h.startdate,h.managername,h.termby,
availsun1,availsun2,availmon1,availmon2,availtue1,availtue2,
availwed1,availwed2,availthur1,availthur2,availfri1,availfri2,
availsat1,availsat2,h.comby,ssn_dash = dbo.SSN_dash(cssn),
Home = dbo.PhoneNumber_complete_format(chphone),
Mobile = dbo.PhoneNumber_complete_format(cmphone),
Other = dbo.PhoneNumber_complete_format(cophone),
Jobtitle =
case
when c.st = '90' then
(select top 1 j.jobtitle from has.dbo.JobCodes j where j.hjob
= h.jobid and
j.hlocation = 'DC')
else
(select top 1 j.jobtitle from has.dbo.JobCodes j where j.hjob
= h.jobid and
j.hlocation <> 'DC')
end,
(Select T.term_reason
From has.dbo.termcodes T, has_arc.dbo.EmpTermHistory H
where T.term_val = H.termcode and h.cid = @cid) as
TermReason,
Days = @day,
Months = @month,
Years = @year
FROM has_arc.dbo.EmpCandidate C, has_arc.dbo.EmpTermHistory H
WHERE C.cid = @cid AND C.cid = H.cid
END
ASP, SQL2005, DW8 VBScript
Can anyone help shed some light on this?
ASP, SQL2005, DW8 VBScript
"Daniel" <[email protected]> wrote in message
news:ff3ud8$10k$[email protected]..
> Not sure if anyone has had this problem, but its getting
annoying.. when i
> execute this within SQL it returns all the values
requested. If i execute
> it within dreamweaver to show me what results i will get
back it works
> there.. but after i bind the fields to my page and view
it only some or
> all my fields do not display any data... but if i play
around with the
> order of my select statement below i can get some fields
to display and
> other disappear... and i dont ever touch my webpage
again...
>
> Can anyone shed some light on this issue? Or is there a
better way to
> display my results so that what i get back with my query
will always
> display....
>
> here is my stored procedure that im calling
> SET NOCOUNT ON;
> SELECT
>
c.cfname,c.clname,c.cid,h.termcode,h.hiredate,h.lastdate,h.cdateh,
> h.cdatet,h.startdate,h.managername,h.termby,
>
availsun1,availsun2,availmon1,availmon2,availtue1,availtue2,
>
availwed1,availwed2,availthur1,availthur2,availfri1,availfri2,
> availsat1,availsat2,h.comby,ssn_dash =
dbo.SSN_dash(cssn),
> Home = dbo.PhoneNumber_complete_format(chphone),
> Mobile = dbo.PhoneNumber_complete_format(cmphone),
> Other = dbo.PhoneNumber_complete_format(cophone),
> Jobtitle =
> case
> when c.st = '90' then
> (select top 1 j.jobtitle from has.dbo.JobCodes j where
j.hjob = h.jobid
> and j.hlocation = 'DC')
> else
> (select top 1 j.jobtitle from has.dbo.JobCodes j where
j.hjob = h.jobid
> and j.hlocation <> 'DC')
> end,
> (Select T.term_reason
> From has.dbo.termcodes T, has_arc.dbo.EmpTermHistory H
> where T.term_val = H.termcode and h.cid = @cid) as
TermReason,
> Days = @day,
> Months = @month,
> Years = @year
>
> FROM has_arc.dbo.EmpCandidate C,
has_arc.dbo.EmpTermHistory H
> WHERE C.cid = @cid AND C.cid = H.cid
> END
>
>
> --
> ASP, SQL2005, DW8 VBScript
>
Similar Messages
-
SQL query / binding issues on my web page
This may or maynot be the place to ask, but maybe someone can
tell me what
to look at...
I created a page some time back.. and its displays a few
fields of data
based on the id passed to it..
This works fine, but now that we are trying to improve the
site a little,
they want some additonal information displayed
on the page.. so those changes were made about 2 weeks ago...
now that some
of the newer records contain the data
they want displayed, some data is not displaying.. or it will
display and
other fields ( that were displaying before ) are now
missing.. the web page hasnt been touched in 2 weeks.. if we
execute the
store procedure within SQL and within our web program
it always returns the correct data.. but the fields that i
have binded to
the page are taking on a life of there own...
Not sure if anyone has had this problem, but its getting
annoying.. when i
execute this within SQL it returns all the values requested.
If i execute it
within dreamweaver to show me what results i will get back it
works there..
but after i bind the fields to my page and view it only some
or all my
fields do not display any data... but if i play around with
the order of my
select statement below i can get some fields to display and
other
disappear... and i dont ever touch my webpage again...
Can anyone shed some light on this issue? Or is there a
better way to
display my results so that what i get back with my query will
always
display....
here is my stored procedure that im calling
SET NOCOUNT ON;
SELECT
c.cfname,c.clname,c.cid,h.termcode,h.hiredate,h.lastdate,h.cdateh,
h.cdatet,h.startdate,h.managername,h.termby,
availsun1,availsun2,availmon1,availmon2,availtue1,availtue2,
availwed1,availwed2,availthur1,availthur2,availfri1,availfri2,
availsat1,availsat2,h.comby,ssn_dash = dbo.SSN_dash(cssn),
Home = dbo.PhoneNumber_complete_format(chphone),
Mobile = dbo.PhoneNumber_complete_format(cmphone),
Other = dbo.PhoneNumber_complete_format(cophone),
Jobtitle =
case
when c.st = '90' then
(select top 1 j.jobtitle from has.dbo.JobCodes j where j.hjob
= h.jobid and
j.hlocation = 'DC')
else
(select top 1 j.jobtitle from has.dbo.JobCodes j where j.hjob
= h.jobid and
j.hlocation <> 'DC')
end,
(Select T.term_reason
From has.dbo.termcodes T, has_arc.dbo.EmpTermHistory H
where T.term_val = H.termcode and h.cid = @cid) as
TermReason,
Days = @day,
Months = @month,
Years = @year
FROM has_arc.dbo.EmpCandidate C, has_arc.dbo.EmpTermHistory H
WHERE C.cid = @cid AND C.cid = H.cid
END
ASP, SQL2005, DW8 VBScriptAnd when it says read the columns left to right... i would
imagine that
means my select statement should select the columns in the
order of which
they are in the tables?
so in my case.. if HomePhone is last column in my table it
should be the
last in the select statement?
ASP, SQL2005, DW8 VBScript
"Daniel" <[email protected]> wrote in message
news:[email protected]...
> Now when you say TEXT type.. your refering to the data
types i have setup
> in the database? correct
>
> Within the database the fields that im querying are
pretty much all
> varchar a few are date and one int
>
>
>
>
> --
> ASP, SQL2005, DW8 VBScript
> "Joris van Lier" <[email protected]> wrote in
message
> news:[email protected]...
>>
>>
>> "Daniel" <[email protected]> wrote in message
>> news:[email protected]...
>>> This may or maynot be the place to ask, but
maybe someone can tell me
>>> what
>>> to look at...
>>>
>>> I created a page some time back.. and its
displays a few fields of data
>>> based on the id passed to it..
>>> This works fine, but now that we are trying to
improve the site a
>>> little,
>>> they want some additonal information displayed
>>> on the page.. so those changes were made about 2
weeks ago... now that
>>> some
>>> of the newer records contain the data
>>> they want displayed, some data is not
displaying.. or it will display
>>> and
>>> other fields ( that were displaying before ) are
now
>>> missing.. the web page hasnt been touched in 2
weeks.. if we execute the
>>> store procedure within SQL and within our web
program
>>> it always returns the correct data.. but the
fields that i have binded
>>> to
>>> the page are taking on a life of there own...
>>>
>>> Not sure if anyone has had this problem, but its
getting annoying.. when
>>> i
>>> execute this within SQL it returns all the
values requested. If i
>>> execute it
>>> within dreamweaver to show me what results i
will get back it works
>>> there..
>>> but after i bind the fields to my page and view
it only some or all my
>>> fields do not display any data... but if i play
around with the order of
>>> my
>>> select statement below i can get some fields to
display and other
>>> disappear... and i dont ever touch my webpage
again...
>>>
>>> Can anyone shed some light on this issue? Or is
there a better way to
>>> display my results so that what i get back with
my query will always
>>> display....
>>>
>>> here is my stored procedure that im calling
>>> SET NOCOUNT ON;
>>> SELECT
>>>
c.cfname,c.clname,c.cid,h.termcode,h.hiredate,h.lastdate,h.cdateh,
>>> h.cdatet,h.startdate,h.managername,h.termby,
>>>
availsun1,availsun2,availmon1,availmon2,availtue1,availtue2,
>>>
availwed1,availwed2,availthur1,availthur2,availfri1,availfri2,
>>> availsat1,availsat2,h.comby,ssn_dash =
dbo.SSN_dash(cssn),
>>> Home = dbo.PhoneNumber_complete_format(chphone),
>>> Mobile =
dbo.PhoneNumber_complete_format(cmphone),
>>> Other =
dbo.PhoneNumber_complete_format(cophone),
>>> Jobtitle =
>>> case
>>> when c.st = '90' then
>>> (select top 1 j.jobtitle from has.dbo.JobCodes j
where j.hjob = h.jobid
>>> and
>>> j.hlocation = 'DC')
>>> else
>>> (select top 1 j.jobtitle from has.dbo.JobCodes j
where j.hjob = h.jobid
>>> and
>>> j.hlocation <> 'DC')
>>> end,
>>> (Select T.term_reason
>>> From has.dbo.termcodes T,
has_arc.dbo.EmpTermHistory H
>>> where T.term_val = H.termcode and h.cid = @cid)
as TermReason,
>>> Days = @day,
>>> Months = @month,
>>> Years = @year
>>>
>>> FROM has_arc.dbo.EmpCandidate C,
has_arc.dbo.EmpTermHistory H
>>> WHERE C.cid = @cid AND C.cid = H.cid
>>> END
>>>
>>>
>>> --
>>> ASP, SQL2005, DW8 VBScript
>>
>>
>> Are any of these fields by chance of TEXT type (or
other Binary Large
>> OBject type)?
>> In this case there are certain limitations the text
fields must be the
>> last in your SQL statement and may only
>> be retrieved ONCE reliably.
>>
>> <%
>> Dim myTextVar
>> myTextVar = Recordset.Fields.Item("TEXTFIELD").value
>> %>
>> <% If NOT IsNull(myTextVar) Then%>
>> <%=(Replace(myTextVar, chr(13),
"<BR>"))%>
>> <% End If ' NOT IsNull(myTextVar) %>
>>
>> Here's an excerpt from the Microsoft Site
>>
>> When dealing with BLOB fields from Microsoft SQL
Server, you must put
>> them
>> to the right of non-BLOB columns in the resultset.
To be safe, you should
>> also read the columns in left-to-right order, so if
you have two BLOB
>> columns as the last two columns in your resultset,
read the first one and
>> then the second. Do not read them in the reverse
order.
>> MS:
http://support.microsoft.com/support/kb/articles/q175/2/39.asp
>>
>> Joris van Lier
>
> -
SQL query performance issues.
Hi All,
I worked on the query a month ago and the fix worked for me in test intance but failed in production. Following is the URL for the previous thread.
SQL query performance issues.
Following is the tkprof file.
CURSOR_ID:76 LENGTH:2383 ADDRESS:f6b40ab0 HASH_VALUE:2459471753 OPTIMIZER_GOAL:ALL_ROWS USER_ID:443 (APPS)
insert into cos_temp(
TRX_DATE, DEPT, PRODUCT_LINE, PART_NUMBER,
CUSTOMER_NUMBER, QUANTITY_SOLD, ORDER_NUMBER,
INVOICE_NUMBER, EXT_SALES, EXT_COS,
GROSS_PROFIT, ACCT_DATE,
SHIPMENT_TYPE,
FROM_ORGANIZATION_ID,
FROM_ORGANIZATION_CODE)
select a.trx_date,
g.segment5 dept,
g.segment4 prd,
m.segment1 part,
d.customer_number customer,
b.quantity_invoiced units,
-- substr(a.sales_order,1,6) order#,
substr(ltrim(b.interface_line_attribute1),1,10) order#,
a.trx_number invoice,
(b.quantity_invoiced * b.unit_selling_price) sales,
(b.quantity_invoiced * nvl(price.operand,0)) cos,
(b.quantity_invoiced * b.unit_selling_price) -
(b.quantity_invoiced * nvl(price.operand,0)) profit,
to_char(to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS'),'DD-MON-RR') acct_date,
'DRP',
l.ship_from_org_id,
p.organization_code
from ra_customers d,
gl_code_combinations g,
mtl_system_items m,
ra_cust_trx_line_gl_dist c,
ra_customer_trx_lines b,
ra_customer_trx_all a,
apps.oe_order_lines l,
apps.HR_ORGANIZATION_INFORMATION i,
apps.MTL_INTERCOMPANY_PARAMETERS inter,
apps.HZ_CUST_SITE_USES_ALL site,
apps.qp_list_lines_v price,
apps.mtl_parameters p
where a.trx_date between to_date('2010/02/01 00:00:00','yyyy/mm/dd HH24:MI:SS')
and to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS')+0.9999
and a.batch_source_id = 1001 -- Sales order shipped other OU
and a.complete_flag = 'Y'
and a.customer_trx_id = b.customer_trx_id
and b.customer_trx_line_id = c.customer_trx_line_id
and a.sold_to_customer_id = d.customer_id
and b.inventory_item_id = m.inventory_item_id
and m.organization_id
= decode(substr(g.segment4,1,2),'01',5004,'03',5004,
'02',5003,'00',5001,5002)
and nvl(m.item_type,'0') <> '111'
and c.code_combination_id = g.code_combination_id+0
and l.line_id = b.interface_line_attribute6
and i.organization_id = l.ship_from_org_id
and p.organization_id = l.ship_from_org_id
and i.org_information3 <> '5108'
and inter.ship_organization_id = i.org_information3
and inter.sell_organization_id = '5108'
and inter.customer_site_id = site.site_use_id
and site.price_list_id = price.list_header_id
and product_attr_value = to_char(m.inventory_item_id)
call count cpu elapsed disk query current rows misses
Parse 1 0.47 0.56 11 197 0 0 1
Execute 1 3733.40 3739.40 34893 519962154 11 188 0
total 2 3733.87 3739.97 34904 519962351 11 188 1
| Rows Row Source Operation
| ------------ ---------------------------------------------------
| 188 HASH JOIN (cr=519962149 pr=34889 pw=0 time=2607.35)
| 741 .TABLE ACCESS BY INDEX ROWID QP_PRICING_ATTRIBUTES (cr=519939426 pr=34889 pw=0 time=2457.32)
| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)
| 741 ....NESTED LOOPS (cr=50042 pr=7230 pw=0 time=11.37)
| 741 .....NESTED LOOPS (cr=48558 pr=7229 pw=0 time=11.35)
| 741 ......NESTED LOOPS (cr=47815 pr=7223 pw=0 time=11.32)
| 3237 .......NESTED LOOPS (cr=41339 pr=7223 pw=0 time=12.42)
| 3237 ........NESTED LOOPS (cr=38100 pr=7223 pw=0 time=12.39)
| 3237 .........NESTED LOOPS (cr=28296 pr=7139 pw=0 time=12.29)
| 1027 ..........NESTED LOOPS (cr=17656 pr=4471 pw=0 time=3.81)
| 1027 ...........NESTED LOOPS (cr=13537 pr=4404 pw=0 time=3.30)
| 486 ............NESTED LOOPS (cr=10873 pr=4240 pw=0 time=0.04)
| 486 .............NESTED LOOPS (cr=10385 pr=4240 pw=0 time=0.03)
| 486 ..............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=9411 pr=4240 pw=0 time=0.02)
| 75253 ...............INDEX RANGE SCAN RA_CUSTOMER_TRX_N5 (cr=403 pr=285 pw=0 time=0.38)
| 486 ..............TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=974 pr=0 pw=0 time=0.01)
| 486 ...............INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=488 pr=0 pw=0 time=0.01)
| 486 .............INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=488 pr=0 pw=0 time=0.01)
| 1027 ............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_LINES_ALL (cr=2664 pr=164 pw=0 time=1.95)
| 2063 .............INDEX RANGE SCAN RA_CUSTOMER_TRX_LINES_N2 (cr=1474 pr=28 pw=0 time=0.22)
| 1027 ...........TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_LINE_GL_DIST_ALL (cr=4119 pr=67 pw=0 time=0.54)
| 1027 ............INDEX RANGE SCAN RA_CUST_TRX_LINE_GL_DIST_N1 (cr=3092 pr=31 pw=0 time=0.20)
| 3237 ..........TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=10640 pr=2668 pw=0 time=15.35)
| 3237 ...........INDEX RANGE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2062 pr=40 pw=0 time=0.33)
| 3237 .........TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=9804 pr=84 pw=0 time=0.77)
| 3237 ..........INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=6476 pr=47 pw=0 time=0.43)
| 3237 ........TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=3239 pr=0 pw=0 time=0.04)
| 3237 .........INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=2 pr=0 pw=0 time=0.01)
| 741 .......TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=6476 pr=0 pw=0 time=0.10)
| 6474 ........INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=3239 pr=0 pw=0 time=0.03)Please help.
Regards
Ashish| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)There is no way the optimizer should choose to process that many rows using nested loops.
Either the statistics are not up to date, the data values are skewed or you have some optimizer parameter set to none default to force index access.
Please post explain plan and optimizer* parameter settings. -
I am trying to see the log file in Manage sessions for the sql query in Answers. I see that if we run the same report multiple times, the sql query is showing up only the first time. Second time if I run it is not showing up. If I do a brand new report with diff columns picked it is giving me the sql then. Where do I set this option to show the sql query everytime I run a report even if it is the same report run multiple times. Is this caching issue?
It shouldn't.... Have you unchecked the "Cache" on the physical layer for this table? If you go onto the Advanced tab, is the option "Bypass the Oracle BI cache" checked?
-
Hi,
Facing Database performance issue while runing overnight batches.
Generate tfprof output for that batch and found some sql query which is having high elapsed time. Could any one please let me know what is the issue for this. It will also be great help if anyone suggest what need to be done as per tuning of this sql queries so as to get better responce time.
Waiting for your reply.
Effected SQL List:
INSERT INTO INVTRNEE (TRANS_SESSION, TRANS_SEQUENCE, TRANS_ORG_CHILD,
TRANS_PRD_CHILD, TRANS_TRN_CODE, TRANS_TYPE_CODE, TRANS_DATE, INV_MRPT_CODE,
INV_DRPT_CODE, TRANS_CURR_CODE, PROC_SOURCE, TRANS_REF, TRANS_REF2,
TRANS_QTY, TRANS_RETL, TRANS_COST, TRANS_VAT, TRANS_POS_EXT_TOTAL,
INNER_PK_TECH_KEY, TRANS_INNERS, TRANS_EACHES, TRANS_UOM, TRANS_WEIGHT,
TRANS_WEIGHT_UOM )
VALUES
(:B22 , :B1 , :B2 , :B3 , :B4 , :B5 , :B21 , :B6 , :B7 , :B8 , :B20 , :B19 ,
NULL, :B9 , :B10 , :B11 , 0.0, :B12 , :B13 , :B14 , :B15 , :B16 , :B17 ,
:B18 )
call count cpu elapsed disk query current rows
Parse 722 0.09 0.04 0 0 0 0
Execute 1060 7.96 83.01 11442 21598 88401 149973
Fetch 0 0.00 0.00 0 0 0 0
total 1782 8.05 83.06 11442 21598 88401 149973
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
UPDATE /*+ ROWID(TRFDTLEE) */TRFDTLEE SET TRF_STATUS = :B2
WHERE
ROWID = :B1
call count cpu elapsed disk query current rows
Parse 635 0.03 0.01 0 0 0 0
Execute 49902 14.48 271.25 41803 80704 355837 49902
Fetch 0 0.00 0.00 0 0 0 0
total 50537 14.51 271.27 41803 80704 355837 49902
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
DECLARE
var_trans_session invtrnee.trans_session%TYPE;
BEGIN
-- ADDED BY SHANKAR ON 08/29/97
-- GET THE NEXT AVAILABLE TRANS_SESSION
bastkey('trans_session',0,var_trans_session,'T');
-- MAS001
uk_trfbapuo_auto(var_trans_session,'UPLOAD','T',300);
-- MAS001 end
END;
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 1 24191.23 24028.57 8172196 10533885 187888 1
Fetch 0 0.00 0.00 0 0 0 0
total 1 24191.23 24028.57 8172196 10533885 187888 1
Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer goal: CHOOSE
SELECT INNER_PK_TECH_KEY
FROM
PRDPCDEE WHERE PRD_LVL_CHILD = :B1 AND LOOSE_PACK_FLAG = 'T'
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 56081 1.90 2.03 0 0 0 0
Fetch 56081 11.07 458.58 53792 246017 0 56081
total 112163 12.98 460.61 53792 246017 0 56081
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
******************First off, be aware of the assumptions I'm making. The SQL you presented above strongly suggests (to me at least) that you have cursor for loops. If that's the case, you need to review what their purpose is and look to convert them into single statement DML commands. For example if you have something like this
DECLARE
ln_Count NUMBER;
ln_SomeValue NUMBER;
BEGIN
FOR lcr_Row IN ( SELECT pk_id,col1,col2 FROM some_table)
LOOP
SELECT
COUNT(*)
INTO
ln_COunt
FROM
target_table
WHERE
pk_id = lcr_Row.pk_id;
IF ln_Count = 0 THEN
SELECT
some_value
INTO
ln_SomeValue
FROM
some_other_table
WHERE
pk_id = lcr_Row.col1
INSERT
INTO
target_table
( pk_id,
some_other_value,
col2
VALUES
( lcr_Row.col1,
ln_SomeValue,
lcr_Row.col2
ELSE
UPDATE
target_table
SET
some_other_value = ln_SomeValue
WHERE
pk_id = lcr_Row.col1;
END IF;
END LOOP;
END; it could be rewritten as
DECLARE
BEGIN
MERGE INTO target_table b
USING ( SELECT
a.pk_id,
a.col2,
b.some_value
FROM
some_table a,
some_other_table b
WHERE
b.pk_id = a.col1
) e
ON (b.pk_id = e.pk_id)
WHEN MATCHED THEN
UPDATE SET b.some_other_value = e.some_value
WHEN NOT MATCHED THEN
INSERT ( b.pk_id,
b.col2,
b.some_other_value)
VALUES( b.pk_id,
b.col2,
b.some_value);
END;It's going to take a bit of analysis and work but the fastest and most scalable way to approach processing data is to use SQL rather than PL/SQL. PL/SQL data processing i.e. cursor loops should be an option of last resort.
HTH
David -
Hey,
Please forgive me if I'm missing something really obvious but it's been a while since I did any SQL work and I'm obviously a bit rusty.
When the below query is run the CPU on the SQL server maxes out. The query itself takes over 6 hours to run.
Is there anything glaringly obvious with the query that might be causing thisCheers
Paul
SELECT TOP (100) PERCENT dbo.CUSTPACKINGSLIPTRANS.ITEMID AS [Stock Code],
dbo.CUSTPACKINGSLIPTRANS.SALESUNIT AS [Unit of Sale],
dbo.DIMENSIONFINANCIALTAG.DESCRIPTION AS [Product Group],
dbo.INVENTITEMGROUP.ITEMGROUPID AS [Item Group],
dbo.INVENTTABLE.SECTION,
dbo.INVENTTABLE.GROUPS AS [Group],
dbo.INVENTTABLE.SUBGROUPS AS [Sub Group],
dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT AS [Cust Account],
dbo.CUSTTABLE.INVOICEACCOUNT AS [Invoice Account],
dbo.DIRPARTYTABLE.NAME AS [Cust Name],
dbo.CUSTTABLE.CURRENCY,
dbo.CUSTTABLE.CIT_CONTROLLER AS [Credit Controller],
dbo.CUSTTABLE.CREDITMAX AS [Credit Limit],
dbo.CUSTTABLE.CUSTCLASSIFICATIONID AS Classification,
dbo.DIRPERSONNAME.FIRSTNAME + ' ' + dbo.DIRPERSONNAME.LASTNAME AS [Sales Person],
dbo.SALESTABLE.SALESGROUP AS [Outside Rooms],
CASE WHEN CUSTTABLE.CUSTCLASSIFICATIONID = 'Cash' THEN dbo.SALESTABLE.SALESGROUP ELSE dbo.CUSTTABLE.SALESGROUP END AS [Sales Rep],
dbo.LOGISTICSPOSTALADDRESS.STATE [Customer Region],
dbo.LOGISTICSPOSTALADDRESS.COUNTY [Customer County],
dbo.CUSTTABLE.LINEOFBUSINESSID AS [Line Of Business],
a.DISPLAYVALUE AS [Site/Location],
dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID AS [Delivery Ref],
dbo.LOGISTICSPOSTALADDRESS.COUNTRYREGIONID,
CONVERT(varchar(12), dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE, 111) AS [Delivery Date],
dbo.LOGISTICSPOSTALADDRESS.ADDRESS AS [Delivery Address],
dbo.CUSTPACKINGSLIPTRANS.VALUEMST AS [Delivery Value (CON)],
CONVERT(varchar(12), dbo.SALESTABLE.RECEIPTDATEREQUESTED, 111) AS [Requested Delivery Date],
dbo.SALESTABLE.SALESID AS [Order Ref],
CASE dbo.SALESTABLE.SALESSTATUS WHEN '0' THEN 'None' WHEN '1' THEN 'Open Order' WHEN '2' THEN 'Delivered' WHEN '3' THEN 'Invoiced' WHEN '4' THEN 'Canceled' END AS [Sales Status],
CASE dbo.SALESTABLE.SALESTYPE WHEN '0' THEN 'Journal' WHEN '1' THEN 'Quotation' WHEN '2' THEN 'Subscription' WHEN '3' THEN 'Sales Order' WHEN '4' THEN 'Returned Item' WHEN '5' THEN 'Blanket Order' WHEN '6' THEN 'Item Requirements' WHEN '7' THEN 'Undefined' END AS [Sales Type],
CASE dbo.SALESTABLE.AG_SALESLOCATION WHEN '0' THEN 'None' WHEN '1' THEN 'OR_DGN' WHEN '2' THEN 'OR_FMT' WHEN '3' THEN 'OR_TME' WHEN '4' THEN 'OR_OMA' WHEN '5' THEN 'DSP_DGN' WHEN '6' THEN 'DSP_FMT' WHEN '7' THEN 'DSP_TME' WHEN '8' THEN 'DSP_OMA' WHEN '9' THEN 'DSP_BEL' WHEN '10' THEN 'DSP_CDF' WHEN '11' THEN 'DSP_BGY' WHEN '12' THEN 'Credit Control' WHEN '13' THEN 'Internal Sales' WHEN '14' THEN 'CP_FMT' WHEN '15' THEN 'GBSales' END AS [Sales Location],
dbo.SALESTABLE.PURCHORDERFORMNUM AS [Customer Requisition],
dbo.SALESLINE.LINEDISC AS [Line Disc],
dbo.SALESLINE.LINEPERCENT AS [Line Percent],
dbo.SALESLINE.PRICEGROUPID AS [Price Group],
dbo.INVENTDIM.INVENTLOCATIONID AS Warehouse,
dbo.DIRPARTYTABLE.NAMEALIAS AS [Search Name],
dbo.CUSTPACKINGSLIPJOUR.LORRYID AS [Lorry ID],
dbo.CUSTPACKINGSLIPJOUR.LORRYREGNO AS [Lorry Reg],
dbo.CUSTPACKINGSLIPJOUR.LORRYDRIVER AS [Lorry Driver],
CASE dbo.SALESLINE.BLOCKED WHEN '0' THEN 'No' WHEN '1' THEN 'Yes' END AS [Stopped?],
dbo.CUSTPACKINGSLIPTRANS.QTY AS [Qty Delivered],
dbo.SALESLINE.SALESPRICE AS [Unit Price],
dbo.CUSTPACKINGSLIPJOUR.CREATEDBY AS [SDN Creator],
MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Month,
YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Year,
DATEPART(week, dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS WeekNo,
CASE MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) WHEN '1' THEN '10' WHEN '2' THEN '11' WHEN '3' THEN '12' WHEN '4' THEN '1' WHEN '5' THEN '2' WHEN '6' THEN '3' WHEN '7' THEN '4' WHEN '8' THEN '5' WHEN '9' THEN '6' WHEN '10' THEN '7' WHEN '11' THEN '8' WHEN '12' THEN '9' END AS [Fin Period], CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)) + '/' + CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) + '/' + CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) + 1)) END AS [Fin Year],
CASE WHEN dbo.custpackingsliptrans.salesunit = '100' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY WHEN dbo.custpackingsliptrans.salesunit = '1000' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY ELSE dbo.CUSTPACKINGSLIPTRANS.QTY END AS [No of Units],
CASE dbo.INVENTITEMGROUPITEM.ITEMGROUPID WHEN 'Mortar' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Sand' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Decorative Gravel' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Crushed Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lintels' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'TBeams' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lime' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) WHEN 'Readymix' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 ELSE (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) / 1000 END AS Tonnage,
dbo.INVENTTABLE.NETWEIGHT AS [Net Weight],
dbo.INVENTTABLE.PRODCOSTA,
dbo.INVENTTABLE.PRODCOSTB,
dbo.INVENTTABLE.PRODCOSTC,
dbo.INVENTTABLE.PRODCOSTD,
dbo.INVENTTABLE.PRODCOSTE,
dbo.INVENTTABLE.PRODCOSTF,
dbo.INVENTTABLE.PRODCOSTG,
dbo.INVENTTABLE.PRODCOSTH,
dbo.INVENTTABLE.QTYPERBALE,
dbo.INVENTTABLE.M2PERBALE,
dbo.SALESTABLE.SALESTYPE,
dbo.SALESTABLE.DLVMODE AS [Delivery Mode],
CONVERT(varchar(12), dbo.SALESTABLE.SHIPPINGDATECONFIRMED, 111) AS [Shipping Date Confirmed],
CONVERT(varchar(12), dbo.SALESTABLE.CREATEDDATETIME, 111) AS [Created Date],
dbo.SALESLINE.CUSTGROUP AS [Cust Group],
dbo.INVENTTABLE.MADETOORDER AS [Made To Order]
FROM dbo.CUSTPACKINGSLIPTRANS INNER JOIN
dbo.CUSTPACKINGSLIPJOUR ON dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID = dbo.CUSTPACKINGSLIPJOUR.PACKINGSLIPID INNER JOIN
dbo.SALESLINE ON dbo.CUSTPACKINGSLIPJOUR.SALESID = dbo.SALESLINE.SALESID AND
dbo.CUSTPACKINGSLIPTRANS.INVENTTRANSID = dbo.SALESLINE.INVENTTRANSID INNER JOIN
dbo.INVENTTABLE ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.INVENTTABLE.ITEMID INNER JOIN
dbo.INVENTITEMGROUPITEM ON dbo.INVENTTABLE.ITEMID = dbo.INVENTITEMGROUPITEM.ITEMID INNER JOIN
dbo.INVENTITEMGROUP ON dbo.INVENTITEMGROUPITEM.ITEMGROUPID = dbo.INVENTITEMGROUP.ITEMGROUPID INNER JOIN
dbo.INVENTDIM ON dbo.SALESLINE.INVENTDIMID = dbo.INVENTDIM.INVENTDIMID INNER JOIN
dbo.CUSTTABLE ON dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT = dbo.CUSTTABLE.ACCOUNTNUM INNER JOIN
dbo.DIRPARTYTABLE ON dbo.CUSTTABLE.PARTY = dbo.DIRPARTYTABLE.RECID INNER JOIN
dbo.LOGISTICSPOSTALADDRESS ON dbo.DIRPARTYTABLE.PRIMARYADDRESSLOCATION = dbo.LOGISTICSPOSTALADDRESS.LOCATION INNER JOIN
dbo.SALESTABLE ON dbo.SALESLINE.SALESID = dbo.SALESTABLE.SALESID INNER JOIN
dbo.DIRPERSONNAME ON dbo.SALESTABLE.WORKERSALESTAKER = dbo.DIRPERSONNAME.RECID INNER JOIN
dbo.ECORESPRODUCT ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.ECORESPRODUCT.SEARCHNAME
AND dbo.INVENTTABLE.ITEMID = dbo.ECORESPRODUCT.DISPLAYPRODUCTNUMBER LEFT OUTER JOIN
dbo.UNITOFMEASURECONVERSION ON dbo.ECORESPRODUCT.RECID = dbo.UNITOFMEASURECONVERSION.PRODUCT LEFT OUTER JOIN
dbo.UNITOFMEASURE ON dbo.UNITOFMEASURECONVERSION.TOUNITOFMEASURE = dbo.UNITOFMEASURE.RECID INNER JOIN
dbo.DEFAULTDIMENSIONVIEW a ON dbo.CUSTPACKINGSLIPTRANS.DEFAULTDIMENSION = a.DEFAULTDIMENSION AND a.NAME = 'Department' LEFT OUTER JOIN
dbo.DEFAULTDIMENSIONVIEW b ON dbo.INVENTTABLE.DEFAULTDIMENSION = b.DEFAULTDIMENSION AND b.NAME = 'Center' INNER JOIN
dbo.DIMENSIONFINANCIALTAG ON b.ENTITYINSTANCE = dbo.DIMENSIONFINANCIALTAG.RECID
WHERE (dbo.CUSTPACKINGSLIPTRANS.DATAAREAID = 'agl') AND
(dbo.CUSTPACKINGSLIPJOUR.DATAAREAID = 'agl') AND
(dbo.SALESLINE.DATAAREAID = 'agl') AND
(dbo.INVENTTABLE.DATAAREAID = 'vuk') AND
(dbo.INVENTDIM.DATAAREAID = 'agl') AND
(dbo.CUSTTABLE.DATAAREAID = 'agl') AND
(dbo.SALESTABLE.DATAAREAID = 'agl') AND
(CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)
WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) END = 2014)Hey,
Please forgive me if I'm missing something really obvious but it's been a while since I did any SQL work and I'm obviously a bit rusty.
When the below query is run the CPU on the SQL server maxes out. The query itself takes over 6 hours to run.
Is there anything glaringly obvious with the query that might be causing thisCheers
Paul
SELECT TOP (100) PERCENT dbo.CUSTPACKINGSLIPTRANS.ITEMID AS [Stock Code],
dbo.CUSTPACKINGSLIPTRANS.SALESUNIT AS [Unit of Sale],
dbo.DIMENSIONFINANCIALTAG.DESCRIPTION AS [Product Group],
dbo.INVENTITEMGROUP.ITEMGROUPID AS [Item Group],
dbo.INVENTTABLE.SECTION,
dbo.INVENTTABLE.GROUPS AS [Group],
dbo.INVENTTABLE.SUBGROUPS AS [Sub Group],
dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT AS [Cust Account],
dbo.CUSTTABLE.INVOICEACCOUNT AS [Invoice Account],
dbo.DIRPARTYTABLE.NAME AS [Cust Name],
dbo.CUSTTABLE.CURRENCY,
dbo.CUSTTABLE.CIT_CONTROLLER AS [Credit Controller],
dbo.CUSTTABLE.CREDITMAX AS [Credit Limit],
dbo.CUSTTABLE.CUSTCLASSIFICATIONID AS Classification,
dbo.DIRPERSONNAME.FIRSTNAME + ' ' + dbo.DIRPERSONNAME.LASTNAME AS [Sales Person],
dbo.SALESTABLE.SALESGROUP AS [Outside Rooms],
CASE WHEN CUSTTABLE.CUSTCLASSIFICATIONID = 'Cash' THEN dbo.SALESTABLE.SALESGROUP ELSE dbo.CUSTTABLE.SALESGROUP END AS [Sales Rep],
dbo.LOGISTICSPOSTALADDRESS.STATE [Customer Region],
dbo.LOGISTICSPOSTALADDRESS.COUNTY [Customer County],
dbo.CUSTTABLE.LINEOFBUSINESSID AS [Line Of Business],
a.DISPLAYVALUE AS [Site/Location],
dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID AS [Delivery Ref],
dbo.LOGISTICSPOSTALADDRESS.COUNTRYREGIONID,
CONVERT(varchar(12), dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE, 111) AS [Delivery Date],
dbo.LOGISTICSPOSTALADDRESS.ADDRESS AS [Delivery Address],
dbo.CUSTPACKINGSLIPTRANS.VALUEMST AS [Delivery Value (CON)],
CONVERT(varchar(12), dbo.SALESTABLE.RECEIPTDATEREQUESTED, 111) AS [Requested Delivery Date],
dbo.SALESTABLE.SALESID AS [Order Ref],
CASE dbo.SALESTABLE.SALESSTATUS WHEN '0' THEN 'None' WHEN '1' THEN 'Open Order' WHEN '2' THEN 'Delivered' WHEN '3' THEN 'Invoiced' WHEN '4' THEN 'Canceled' END AS [Sales Status],
CASE dbo.SALESTABLE.SALESTYPE WHEN '0' THEN 'Journal' WHEN '1' THEN 'Quotation' WHEN '2' THEN 'Subscription' WHEN '3' THEN 'Sales Order' WHEN '4' THEN 'Returned Item' WHEN '5' THEN 'Blanket Order' WHEN '6' THEN 'Item Requirements' WHEN '7' THEN 'Undefined' END AS [Sales Type],
CASE dbo.SALESTABLE.AG_SALESLOCATION WHEN '0' THEN 'None' WHEN '1' THEN 'OR_DGN' WHEN '2' THEN 'OR_FMT' WHEN '3' THEN 'OR_TME' WHEN '4' THEN 'OR_OMA' WHEN '5' THEN 'DSP_DGN' WHEN '6' THEN 'DSP_FMT' WHEN '7' THEN 'DSP_TME' WHEN '8' THEN 'DSP_OMA' WHEN '9' THEN 'DSP_BEL' WHEN '10' THEN 'DSP_CDF' WHEN '11' THEN 'DSP_BGY' WHEN '12' THEN 'Credit Control' WHEN '13' THEN 'Internal Sales' WHEN '14' THEN 'CP_FMT' WHEN '15' THEN 'GBSales' END AS [Sales Location],
dbo.SALESTABLE.PURCHORDERFORMNUM AS [Customer Requisition],
dbo.SALESLINE.LINEDISC AS [Line Disc],
dbo.SALESLINE.LINEPERCENT AS [Line Percent],
dbo.SALESLINE.PRICEGROUPID AS [Price Group],
dbo.INVENTDIM.INVENTLOCATIONID AS Warehouse,
dbo.DIRPARTYTABLE.NAMEALIAS AS [Search Name],
dbo.CUSTPACKINGSLIPJOUR.LORRYID AS [Lorry ID],
dbo.CUSTPACKINGSLIPJOUR.LORRYREGNO AS [Lorry Reg],
dbo.CUSTPACKINGSLIPJOUR.LORRYDRIVER AS [Lorry Driver],
CASE dbo.SALESLINE.BLOCKED WHEN '0' THEN 'No' WHEN '1' THEN 'Yes' END AS [Stopped?],
dbo.CUSTPACKINGSLIPTRANS.QTY AS [Qty Delivered],
dbo.SALESLINE.SALESPRICE AS [Unit Price],
dbo.CUSTPACKINGSLIPJOUR.CREATEDBY AS [SDN Creator],
MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Month,
YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Year,
DATEPART(week, dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS WeekNo,
CASE MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) WHEN '1' THEN '10' WHEN '2' THEN '11' WHEN '3' THEN '12' WHEN '4' THEN '1' WHEN '5' THEN '2' WHEN '6' THEN '3' WHEN '7' THEN '4' WHEN '8' THEN '5' WHEN '9' THEN '6' WHEN '10' THEN '7' WHEN '11' THEN '8' WHEN '12' THEN '9' END AS [Fin Period], CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)) + '/' + CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) + '/' + CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) + 1)) END AS [Fin Year],
CASE WHEN dbo.custpackingsliptrans.salesunit = '100' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY WHEN dbo.custpackingsliptrans.salesunit = '1000' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY ELSE dbo.CUSTPACKINGSLIPTRANS.QTY END AS [No of Units],
CASE dbo.INVENTITEMGROUPITEM.ITEMGROUPID WHEN 'Mortar' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Sand' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Decorative Gravel' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Crushed Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lintels' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'TBeams' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lime' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) WHEN 'Readymix' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 ELSE (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) / 1000 END AS Tonnage,
dbo.INVENTTABLE.NETWEIGHT AS [Net Weight],
dbo.INVENTTABLE.PRODCOSTA,
dbo.INVENTTABLE.PRODCOSTB,
dbo.INVENTTABLE.PRODCOSTC,
dbo.INVENTTABLE.PRODCOSTD,
dbo.INVENTTABLE.PRODCOSTE,
dbo.INVENTTABLE.PRODCOSTF,
dbo.INVENTTABLE.PRODCOSTG,
dbo.INVENTTABLE.PRODCOSTH,
dbo.INVENTTABLE.QTYPERBALE,
dbo.INVENTTABLE.M2PERBALE,
dbo.SALESTABLE.SALESTYPE,
dbo.SALESTABLE.DLVMODE AS [Delivery Mode],
CONVERT(varchar(12), dbo.SALESTABLE.SHIPPINGDATECONFIRMED, 111) AS [Shipping Date Confirmed],
CONVERT(varchar(12), dbo.SALESTABLE.CREATEDDATETIME, 111) AS [Created Date],
dbo.SALESLINE.CUSTGROUP AS [Cust Group],
dbo.INVENTTABLE.MADETOORDER AS [Made To Order]
FROM dbo.CUSTPACKINGSLIPTRANS INNER JOIN
dbo.CUSTPACKINGSLIPJOUR ON dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID = dbo.CUSTPACKINGSLIPJOUR.PACKINGSLIPID INNER JOIN
dbo.SALESLINE ON dbo.CUSTPACKINGSLIPJOUR.SALESID = dbo.SALESLINE.SALESID AND
dbo.CUSTPACKINGSLIPTRANS.INVENTTRANSID = dbo.SALESLINE.INVENTTRANSID INNER JOIN
dbo.INVENTTABLE ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.INVENTTABLE.ITEMID INNER JOIN
dbo.INVENTITEMGROUPITEM ON dbo.INVENTTABLE.ITEMID = dbo.INVENTITEMGROUPITEM.ITEMID INNER JOIN
dbo.INVENTITEMGROUP ON dbo.INVENTITEMGROUPITEM.ITEMGROUPID = dbo.INVENTITEMGROUP.ITEMGROUPID INNER JOIN
dbo.INVENTDIM ON dbo.SALESLINE.INVENTDIMID = dbo.INVENTDIM.INVENTDIMID INNER JOIN
dbo.CUSTTABLE ON dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT = dbo.CUSTTABLE.ACCOUNTNUM INNER JOIN
dbo.DIRPARTYTABLE ON dbo.CUSTTABLE.PARTY = dbo.DIRPARTYTABLE.RECID INNER JOIN
dbo.LOGISTICSPOSTALADDRESS ON dbo.DIRPARTYTABLE.PRIMARYADDRESSLOCATION = dbo.LOGISTICSPOSTALADDRESS.LOCATION INNER JOIN
dbo.SALESTABLE ON dbo.SALESLINE.SALESID = dbo.SALESTABLE.SALESID INNER JOIN
dbo.DIRPERSONNAME ON dbo.SALESTABLE.WORKERSALESTAKER = dbo.DIRPERSONNAME.RECID INNER JOIN
dbo.ECORESPRODUCT ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.ECORESPRODUCT.SEARCHNAME
AND dbo.INVENTTABLE.ITEMID = dbo.ECORESPRODUCT.DISPLAYPRODUCTNUMBER LEFT OUTER JOIN
dbo.UNITOFMEASURECONVERSION ON dbo.ECORESPRODUCT.RECID = dbo.UNITOFMEASURECONVERSION.PRODUCT LEFT OUTER JOIN
dbo.UNITOFMEASURE ON dbo.UNITOFMEASURECONVERSION.TOUNITOFMEASURE = dbo.UNITOFMEASURE.RECID INNER JOIN
dbo.DEFAULTDIMENSIONVIEW a ON dbo.CUSTPACKINGSLIPTRANS.DEFAULTDIMENSION = a.DEFAULTDIMENSION AND a.NAME = 'Department' LEFT OUTER JOIN
dbo.DEFAULTDIMENSIONVIEW b ON dbo.INVENTTABLE.DEFAULTDIMENSION = b.DEFAULTDIMENSION AND b.NAME = 'Center' INNER JOIN
dbo.DIMENSIONFINANCIALTAG ON b.ENTITYINSTANCE = dbo.DIMENSIONFINANCIALTAG.RECID
WHERE (dbo.CUSTPACKINGSLIPTRANS.DATAAREAID = 'agl') AND
(dbo.CUSTPACKINGSLIPJOUR.DATAAREAID = 'agl') AND
(dbo.SALESLINE.DATAAREAID = 'agl') AND
(dbo.INVENTTABLE.DATAAREAID = 'vuk') AND
(dbo.INVENTDIM.DATAAREAID = 'agl') AND
(dbo.CUSTTABLE.DATAAREAID = 'agl') AND
(dbo.SALESTABLE.DATAAREAID = 'agl') AND
(CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)
WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) END = 2014)
Try to minimize joins using intermediary tables, also you can consider limiting data based on date ranges and codes (DATAAREAID) before joining with other tables. -
A query run by the 'tom' user who searches on (xyz crieteria) takes less than 5 seconds.
However, when the user 'greg' ruuns the same query, it take > 14 minutes to execute for same xyz crieteria.
Note:both are application users and internally use DOCD database user.Both are using same SQL Explain plan but diffrence is disk read in case of long running query.
my question is if both queries are same and using same explain plan and returning same rows why there is disk read???? and such huge diffrence in execution time...Below is the tkprof output for both the queries.
QUICK QUERY
===========
SELECT E_NAME, E_CURVER_NUM, E_CURVER_CKO, E_PROTECTED, E_INA01, E_INA26,
E_INA47, V_FILE_NAME, E_ICON_TITLE, E_INA41, E_INA11, E_INA16, E_INA40,
E_INA15, E_INA35, E_ORG_FILENAME, E_COMMENT, E_INA28, E_INA27,
E_CREATE_DATE, E_OWNER, E_LAST_DATE, V_CHECKED_OUT, V_CHECKIN_USER, V_NAME,
V_E_NAME, V_AVAIL_STAT, V_RECLAIM, V_PERMANENT, V_CSI_STATUS, V_CD, E_INA01,
V_INA03, V_INA02, V_INA04, E_INA02, V_INA01, V_CREATE_DATE, E_INA03
FROM
ELEMENT, VERSION WHERE (NLS_UPPER(E_INA01) LIKE NLS_UPPER(:V001) AND
NLS_UPPER(E_INA26) = NLS_UPPER(:V002) AND E_INA02 IS NULL AND (E_INA03 IS
NULL OR E_INA03 = :V003) AND V_BRANCH_CURVER = :V004) AND ELEMENT.E_NAME =
VERSION.V_E_NAME ORDER BY 12, 10 DESC, 1, 26, 25
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 167 0.18 0.18 0 29466 0 1002
total 169 0.20 0.19 0 29466 0 1002
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer goal: CHOOSE
Parsing user id: 41
Rows Row Source Operation
1002 SORT ORDER BY (cr=29466 r=0 w=0 time=179192 us)
8847 NESTED LOOPS (cr=29466 r=0 w=0 time=146638 us)
14191 TABLE ACCESS FULL VERSION (cr=1082 r=0 w=0 time=25337 us)
8847 TABLE ACCESS BY INDEX ROWID ELEMENT (cr=28384 r=0 w=0 time=97209 us)
14191 INDEX UNIQUE SCAN UI256 (cr=14193 r=0 w=0 time=30388 us)(object id 29956)
SLOW QUERY
==========
SELECT E_NAME, E_CURVER_NUM, E_CURVER_CKO, E_PROTECTED, E_INA01, E_INA26,
E_INA47, V_FILE_NAME, E_ICON_TITLE, E_INA41, E_INA11, E_INA16, E_INA40,
E_INA15, E_INA35, E_ORG_FILENAME, E_COMMENT, E_INA28, E_INA27,
E_CREATE_DATE, E_OWNER, E_LAST_DATE, V_CHECKED_OUT, V_CHECKIN_USER, V_NAME,
V_E_NAME, V_AVAIL_STAT, V_RECLAIM, V_PERMANENT, V_CSI_STATUS, V_CD, E_INA01,
V_INA03, V_INA02, V_INA04, E_INA02, V_INA01, V_CREATE_DATE, E_INA03
FROM
ELEMENT, VERSION WHERE (NLS_UPPER(E_INA01) LIKE NLS_UPPER(:V001) AND
NLS_UPPER(E_INA26) = NLS_UPPER(:V002) AND E_INA02 IS NULL AND (E_INA03 IS
NULL OR E_INA03 = :V003) AND V_BRANCH_CURVER = :V004) AND ELEMENT.E_NAME =
VERSION.V_E_NAME ORDER BY 12, 10 DESC, 1, 26, 25
call count cpu elapsed disk query current rows
Parse 1 0.01 0.02 2 2 0 0
Execute 1 0.01 0.00 0 0 0 0
Fetch 167 0.29 1.18 2389 29466 0 1002
total 169 0.32 1.21 2391 29468 0 1002
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer goal: CHOOSE
Parsing user id: 41
Rows Row Source Operation
1002 SORT ORDER BY (cr=29466 r=2389 w=0 time=1180072 us)
8847 NESTED LOOPS (cr=29466 r=2389 w=0 time=1144811 us)
14191 TABLE ACCESS FULL VERSION (cr=1082 r=1078 w=0 time=134164 us)
8847 TABLE ACCESS BY INDEX ROWID ELEMENT (cr=28384 r=1311 w=0 time=984455 us)
14191 INDEX UNIQUE SCAN UI256 (cr=14193 r=137 w=0 time=127843 us)(object id 29956)Anuj,
In the future, when posting items to the forum where spacing is critical to proper understanding, please use the { code } tags (without spaces) to retain the spacing.
It appears that there is more to the story than what has been reported. It is good that you used tkprof, as it shows that there is more to the story. Taking a look at the two executions, the tkprof output shows that the first (quick) execution completed in 0.19 seconds, while the second (slow) execution completed in 1.21 seconds, even with th 2,391 blocks read from disk. My first question, if I were in the same situation, would be what would cause the first execution time to jump from 0.19 seconds to 5 seconds, and the second execution to jump from 1.21 seconds to 840 seconds (14 minutes)?
In both cases, there is a library cache miss on both the parse and the execute calls - there may be some significance to this.
In both cases, there were 167 fetch calls to return 1,002 rows, meaning that on average 6 rows were returned on each fetch.
Let's assume that 'tom', whose query executed quickly, was connected to the database over a T1 connection with a 20ms (0.02 second) ping time. For siimplicity in calculation, assume that there were 170 round trips between the server and the client. The network communication between the client and the server would require at least 3.4 seconds, for a total time to send the query and retrieve the results of about 3.6 seconds. This is a little short of 5 seconds which you reported.
Let's assume that 'greg', whose query executed slowly, was connected to the database over a satellite connection with a 2000ms (2 second) ping time. With the same number of round trips, the network communication would require about 340 seconds, for a total time to send the query and retrieve the results of about 341.21 seconds (5.7 minutes), about 8 minutes short of the target 14 minutes.
Was this the only query executed by the clients, or were there multiple queries?
Were the client computers on the same network segment?
Did you gather a 10046 trace at level 8 or 12 for the sessions? If so, manually review the wait events in the trace files to see if it is possible to determine what was happening during the 14 minutes. Guessing can be fun, but sometimes you come up 8 minutes short by guessing alone.
Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Need some guidance - SQL Query Bind Variables for VO Object
Hi,
I'm trying to customize a custom page and I'm new to this. Can you please guide me or send me an example on how to do this?
1) VO is having the query as "SELECT INVOICE_NUM, INVOICE_DATE, INVOICE_AMOUNT, ...... from AP_INVOICES_ALL" (no parameters in the where clause)
2) Added VO to AM
3) XML PG is designed with MainRN, QueryRN, and Instance of VO1 as Table region. Selected INVOICE_NUM, INVOICE_DATE as Searchable. QueryRN is ResultbasesSearch.
4) Deployed to E-Biz and users were able to query using INVOICE_NUM or INVOICE_DATE fields that are available in the QueryRN.
Now, they want to add FROM_INVOICE_DATE and TO_INVOICE_DATE to the Search Condition. So, I have added the condition in the VO Query as "SELECT INVOICE_NUM, INVOICE_DATE, INVOICE_AMOUNT, ...... from AP_INVOICES_ALL WHERE INVOICE_DATE between :0 and :1".
How to add these fields FROM_INVOICE_DATE and TO_INVOICE_DATE to the QueryRN? These are not part of VO.
How to bind them to :0 and :1? I don't see any controller here? Do I need set a new controller and write logic for getting result set?
Any sample script or link would really help.
Thanks in advance.
RamHi Ram,
Hmmm, it is interesting.
Add two attributes to the page fromDate and toDate and in the controller class capture the values (like String fromDate = pageContext.getParameter("FromDate");) and invoke a method from AM and pass these parameters.
In the AM method call a method of VO and the VOImpl set and pass the bind parameters and execute the query again.
like
setWhereClause(" from_date = :1 AND to_date = :2");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, fromDate);
setWhereClauseParam(1, toDate);
executeQuery();
Hope this will answer your question.
Krishna. -
Report pl/sql function body returning query bind variable
I really like using report with a function returning sql. I have been using something like this
declare
q varchar2(10000);
begin
q := 'select col1
from mytable
.... add a dynamic where clause ....
return q;
end;
But I thought it would be nice to store the query in a bind variable so that I could show the where clause. I tried to create an item P123_Q and do the following:
declare
q varchar2(10000);
begin
q := 'select col1
from mytable
.... add a dynamic where clause ....
:P123_Q := q;
return q;
end;
But the parser treats :P123_Q as if it is a bind variable within flow 4000. I found a workaround but I'm wondering if there is a better way.
My workaround is to set a preference in the query and then use a computation that sets P123_Q to the value of the preference:
declare
q varchar2(10000);
begin
q := 'select col1
from mytable
.... add a dynamic where clause l_q := l_q || ....
HTMLDB_UTIL.SET_PREFERENCE(
p_preference => 'Q',
p_value => q,
p_user => :APP_USER);;
return q;
end;
Any thoughts on another way?
thanks,
AntonAnton,if htmldb_application.get_current_flow_sgid(:APP_ID) = htmldb_application.get_sgid then
:P1_X := l_sql;
end if;Scott -
Issue with SQL Query with Presentation Variable as Data Source in BI Publisher
Hello All
I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
select TILE4,max(APPTS), 'Top Count' from
SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0)) AS TILE4,
c4 as dept,c6 as month FROM
select sum(case when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
sum(case when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
T802.NAME_LEVEL_6 as c3,
T802.NAME_LEVEL_1 as c4,
T6172.CALENDARMONTHNAMEANDYEAR as c5,
T6172.CALENDARMONTHNUMBERINYEAR as c6,
T802.DEPT_CODE as c7
from
DW_date_DIM T6736 /* z_dim_date */ ,
DW_MONTH_DIM T6172 /* z_dim_month */ ,
DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
where ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 = '@{PV_D}{RSD}'
and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6) and substr('@{Month_END}',8,13))
and (T6736.TYPE in ('Call Center', 'LSM')) )
group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
order by c4, c3, c6, c7, c5
))where tile4=3 group by tile4
When I try to view data after creating the data set, I get the following error:
Failed to load XML
XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
So I know it is the PV that's causing this error.
How can I work around it?
There is no way to create equivalent report without using the direct sql..
Thanks in advanceI have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
or more descriptive errors.
//Jonas -
SQL query with Bind variable with slower execution plan
I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
Execution Plan
0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
(Cost=2 Card=135 Bytes=6480)
Statistics
0 recursive calls
18 db block gets
15558 consistent gets
47 physical reads
9896 redo size
423 bytes sent via SQL*Net to client
1095 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
55 rows processed
I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
Execution Plan
0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
Statistics
0 recursive calls
12 db block gets
3003199 consistent gets
54 physical reads
9448 redo size
423 bytes sent via SQL*Net to client
1258 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
55 rows processed
TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
Regards
IvanMany thanks for your reply.
I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
for table I use:-
begin
dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
end;
for index I use:-
begin
dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
end;
Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
regards
Ivan -
Can I put a SQL query into a bind variable and then use it to output report
Hi,
Can I put a SQL query into a bind variable and then use it to output report?
I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
select * from (:P1_TEXT);
Do you think it is possible to do that? Any known limitations for APEX in this area?
Thanks a lot,
AngelaYou can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
Tyler -
Goods Issue - SQL Query will not sum
I have 3 Goods Issue documents with Document Total for each document 10,000 / 20,000 / 30,000 subsequently.
I want to make query so that it will display like below - where it shows BOTH each of 3 document value (10000/2000/30000) AND the sum of the 3 documents (60000) like below.
Doc 1 - 10,000
Doc 2 - 20,000
Doc 3 - 30,000
Total = 60,000
In addition, I would like the ability to choose date range. Basically, something like
SELECT Document_Total
FROM Goods_Issue table
WHERE the_document_date is between 1-SEP-2011 and 31-SEP-2011
AND the_reference_is _________________
I have tried many SQL queries, but it displayed either:
Doc 1 - 10,000
Doc 2 - 20,000
Doc 3 - 30,000
OR
Total = 60,000
Please help.@Hendry Wijaya @GordonDu @malhaar
Thanks for helps. The SQL query you provided solved 99% of the problem. I just need to make a tweak on the SQL so that it could display the total on the footer. See screenshot below - I uploaded the pics at imageshack as I don't find a way to attach pics in here.
[See here - Total_at_Footer|http://i129.photobucket.com/albums/p213/whitesnowbear/AAAA/Untitled-2.jpg]
Thanks a bunch. -
Oracle Sql Query issue Running on Different DB Version
Hello All,
I have come into situation where we are pruning sql queries on different DB version of Oracle and have performance issue. Let me tell you in brief and i really appreciate for your prompt response as its very imperative stuff.
I have a query which is running on a DB of version 7.3.4 and it takes around 30 mins where as the same query when run on 8i it takes 15sec., its a huge difference. I have run the statistics to analyze on 7.3 and its comparatively very high. Question here is, the sql query trys to select data from same schema table and 2 tables from another DB using DB link and 2 other tables from another DB using DB link.So,how can we optimize this stuff and achieve this run as same time as 8i DB in 7.3. Hope i am clear about my question, Eagerly waiting for your replies.
Thanks in Advance.
Message was edited by:
Ram8Difficult to be sure without any more detailed information, but I suspect that O7 is in effect copying the remote tables to local temp space, then joining; 8i is factoring out a better query to send to the remote DBs, which does as much work as possible on the remote DB before shipping remaining rows back to local.
You should be able to use EXPLAIN PLAN to identify what SQL is being shipped to the remote DB, If you can't (and it's been quite a while since I tried DB links or O7) then get the remote DBs to yourself, and set SQL_TRACE on for the remote instances. Execute the query and then examine the remote trace files, And don't forget to turn off the tracing when you're done.
Of course it could just be that the CBO got better,,,
HTH - if not, post your query and plans for the local db, and the remote queries.
Regards Nigel -
Passing values in a vector list as bind variables in sql query.
Hi,
I have a vector list containing values 12,13,14.
vector<string> v;
v has values 12,13 and 14.
Here the number of values in vector list are not fixed.
I want to pass these values as bind variables to sql query.
Can anyone suggest me how to do this.
Thanks in advance!!Ah, the it's the classic 'Varying In-List' again
See:
The Tom Kyte Blog: Varying in lists...
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples)
Maybe you are looking for
-
NEGATIVE_ACKNOWLEDGEMENT
Pessoal, boa tarde, O GRC funcioava normalmente e derepente parou de funcionar somente para MG no senario de LOTE, no monitor o Status de MG está OK, sendo que não fiz nenhuma alteração. Estou com o seguiente erro, Quando está sendo executado o Sena
-
Old compy's hard drive erased-how do i get songs back on new compy?
kinda complicated... had itunes and ipod mini for about 1 1/2 years. My lovely computer's hard drive was completely wiped out by a virus (and i wasnt maintaining it well =/) and my parents bought me a new compy. I still listen to my ipod mini... but
-
Hi all, I am configuring a scenario RFC -> XI -> Webservice. In my SOAP adapter trace, i found an error : <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1"> <SAP:Ca
-
Question about GUI Design on JTable and its separate editor
Hi all, I need to use JTable with separate editor , that way when I double click one of the JTable's row its editor will popup in another window. Based on GUI design principles, where should I put the editor, in another tab panel or a JDialog ? Any a
-
Hi, Two days before i changed my domain administrator password and after that my "start edge sync" for Edge server does not work. It gives me an error " The supplied credential is invalid". Please help. Thanks