Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Performanceproblem with subquery to Oracle Linked Server

 
   Database Help (Home) -> Connect RSS
Next:  Security Q:  
Author Message
Christian Mersch

External


Since: Feb 10, 2005
Posts: 1



(Msg. 1) Posted: Fri Feb 11, 2005 12:23 am
Post subject: Performanceproblem with subquery to Oracle Linked Server
Archived from groups: microsoft>public>sqlserver>connect, others (more info?)

Hello

I hope anyone can help me here with a Problem between my Microsoft SQL
Server 2000 SP 3 and an Oracle 8 Server. I have to copy records from a Oracle
table (3.000.000 records by now) to a SQL Server table (8.000.000 records by
now) daily (somthing like an incremental backup). The Oracle Server is
configured as Linked Server and I use the following SQL statement to do this:

INSERT INTO CALLDETAIL
(CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...)

SELECT CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...
from ORACLE..ACC.CALLDETAIL
WHERE TERM_DATE > (SELECT MAX(TERM_DATE) FROM CALLDETAIL)

The query is placed in a DTS and runs once a day and normally copies between
4000 and 5000 rows. My problem is that the query takes between 90 and 130
minutes but when I use a hardcoded date instead of the subquery it only takes
2 minutes maximum. The subquery itself runs only 1-2 sec. As soon as I dont
use a hardcoded date it takes hours. I tried it by using the Query Analyzer
and placing the date in a int variable to used it instead of the subquery.

declare @datevalue int
set @datevalue = 1050208
SELECT CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...
from ORACLE..ACC.CALLDETAIL
WHERE TERM_DATE > @datevalue

I tried the Microsoft and the Oracle OLEDB Provider without success.
Even the OPENQUERY function hadn't helped because I can't use a dynamic
datevalue within the OPENQUERY function. Has anyone an Idea what I have to do
to improve the performance ?

 >> Stay informed about: Performanceproblem with subquery to Oracle Linked Server 
Back to top
Login to vote
oj

External


Since: Aug 24, 2003
Posts: 91



(Msg. 2) Posted: Fri Feb 11, 2005 1:05 am
Post subject: Re: Performanceproblem with subquery to Oracle Linked Server [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I would use dynamic query + pass-through.

e.g.
declare @sql nvarchar(1000)
set @sql='select *
from openquery(oracle,''select a,b,c from tb where
term_date>'+cast(@datevalue as nvarchar)+''') as pt'

insert into localtb(a,b,c)
exec(@sql)


--
-oj


"Christian Mersch" wrote in
message
 > Hello
 >
 > I hope anyone can help me here with a Problem between my Microsoft SQL
 > Server 2000 SP 3 and an Oracle 8 Server. I have to copy records from a
 > Oracle
 > table (3.000.000 records by now) to a SQL Server table (8.000.000 records
 > by
 > now) daily (somthing like an incremental backup). The Oracle Server is
 > configured as Linked Server and I use the following SQL statement to do
 > this:
 >
 > INSERT INTO CALLDETAIL
 > (CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...)
 >
 > SELECT CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...
 > from ORACLE..ACC.CALLDETAIL
 > WHERE TERM_DATE > (SELECT MAX(TERM_DATE) FROM CALLDETAIL)
 >
 > The query is placed in a DTS and runs once a day and normally copies
 > between
 > 4000 and 5000 rows. My problem is that the query takes between 90 and 130
 > minutes but when I use a hardcoded date instead of the subquery it only
 > takes
 > 2 minutes maximum. The subquery itself runs only 1-2 sec. As soon as I
 > dont
 > use a hardcoded date it takes hours. I tried it by using the Query
 > Analyzer
 > and placing the date in a int variable to used it instead of the subquery.
 >


 > SELECT CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...
 > from ORACLE..ACC.CALLDETAIL

 >
 > I tried the Microsoft and the Oracle OLEDB Provider without success.
 > Even the OPENQUERY function hadn't helped because I can't use a dynamic
 > datevalue within the OPENQUERY function. Has anyone an Idea what I have to
 > do
 > to improve the performance ?
 >

 >> Stay informed about: Performanceproblem with subquery to Oracle Linked Server 
Back to top
Login to vote
Christian Mersch

External


Since: Feb 11, 2005
Posts: 1



(Msg. 3) Posted: Fri Feb 11, 2005 8:45 am
Post subject: Re: Performanceproblem with subquery to Oracle Linked Server [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

@oj Thanks for the immidiate answer.

Now the "SELECT part" works fine but if I use it in association with the
INSERT statement I get the message:
-----------------------------------------------------
|Server: Msg 8522, Level 18, State 1, Line 31|
|Distributed transaction aborted by MSDTC. |
-----------------------------------------------------

declare @datevalue int
declare @str_sql nvarchar(1000)
select @datevalue=max(term_date)-1 from report_nl.dbo.calldetail

set @str_sql='select *
from openquery(ORACLE,''SELECT CALL_TYPE,TRANS_TYPE,DISPOSITION,
RING_TIME,QUEUE_TIME, DELAY_TIME,HOLD_TIME,TALK_TIME,
  WRAPUP_TIME,CTYPE_TIME,DIAL_TIME,NETWORK_TIME,SELECT_TIME,
  NUM_SELECT,HANDWS,ORIG,ORIG_TYPE,ORIG_GROUP,
  DEST,DEST_TYPE,DEST_GROUP,ASS_PARTY,ASS_TYPE,
  APPLIC_NUM,DNIS_DIGIT,DIAL_DIGIT,CALLDATA_A,CALLDATA_B,
  CALLDATA_C,CALLDATA_D,CALLDATA_F,CFLAG,CFLAG1,CFLAG2,
  NOISE,VOLUME,ECHO,ORIG_DATE,ORIG_TIME,TERM_DATE,
  TERM_TIME,CALL_ID,TRACK_NODE,TRACK_NUM,TRACK_SEQNO,
  TO_NODE,FROM_NODE,NUM_ACC_IFLOW,NUM_REJ_IFLOW,
  NUM_NET_ERR,NUM_REJ_LOCAL,MISC_1,MISC_2,MISC_3,MISC_4,
  IPNIQ_ROUTING
from CALLDETAIL where TERM_DATE >'+cast(@datevalue as nvarchar)+''') as pt'
--execute (@str_sql)

insert into calldetail
  (CALL_TYPE,TRANS_TYPE,DISPOSITION,RING_TIME,
  QUEUE_TIME, DELAY_TIME,HOLD_TIME,TALK_TIME,
  WRAPUP_TIME,CTYPE_TIME,DIAL_TIME,NETWORK_TIME,SELECT_TIME,
  NUM_SELECT,HANDWS,ORIG,ORIG_TYPE,ORIG_GROUP,
  DEST,DEST_TYPE,DEST_GROUP,ASS_PARTY,ASS_TYPE,
  APPLIC_NUM,DNIS_DIGIT,DIAL_DIGIT,CALLDATA_A,CALLDATA_B,
  CALLDATA_C,CALLDATA_D,CALLDATA_F,CFLAG,CFLAG1,CFLAG2,
  NOISE,VOLUME,ECHO,ORIG_DATE,ORIG_TIME,TERM_DATE,
  TERM_TIME,CALL_ID,TRACK_NODE,TRACK_NUM,TRACK_SEQNO,
  TO_NODE,FROM_NODE,NUM_ACC_IFLOW,NUM_REJ_IFLOW,
  NUM_NET_ERR,NUM_REJ_LOCAL,MISC_1,MISC_2,MISC_3,MISC_4,
  IPNIQ_ROUTING)

execute (@str_sql)

If I run the upper part until the first execute only it works fine(4700 Rows
within 24 seconds) but if i try to run the complete statement i get the error
message.

I've checked the reg keys for the Oracle driver and the MSDTC Servie but it
looks like everything is OK. (KB280106)
If I set IMPLICIT_TRANSACTIONS ON the error message comes after the
COMMIT step.

By the way I have to correct the Information about the used Oracle Version.
It's not an Oracle 8 it's an Oracle 7.3.

Any ideas how to get it working ?


"oj" wrote:

 > I would use dynamic query + pass-through.
 >
 > e.g.


 > from openquery(oracle,''select a,b,c from tb where

 >
 > insert into localtb(a,b,c)

 >
 >
 > --
 > -oj
 >
 >> Stay informed about: Performanceproblem with subquery to Oracle Linked Server 
Back to top
Login to vote
Janthijs

External


Since: Feb 22, 2005
Posts: 1



(Msg. 4) Posted: Tue Feb 22, 2005 8:38 am
Post subject: Re: Performanceproblem with subquery to Oracle Linked Server [Login to view extended thread Info.]
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Hello,

There is a way to use OPENQUERY dynamically. I have no idea if this will solve your problem. Please let me know.

declare @datevalue int
declare @query as varchar(8000)

set @datevalue = 1050208

select @query='
INSERT INTO CALLDETAIL SELECT *
FROM OPENQUERY(OracleSvr, ''SELECT CALL_TYPE,TRANS_TYPE,DISPOSITION,....46more fields...
from ORACLE..ACC.CALLDETAIL
WHERE TERM_DATE > '+@datevalue+' '')'

exec (@query)

Best regards,
Janthijs

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 >> Stay informed about: Performanceproblem with subquery to Oracle Linked Server 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Oracle linked Server - Hello, I have a SQL 2003 SP3a on Windows 2003 and am connecting to an Oracle 9i database. I've set up the linked server and necessary permissions and it has been working successfully for months. However occasionally after rebooting the machine I..

Linked Server Connection and CONCAT_NULL_YIELDS_NULL - Hello I have question to linked Server Connection from a SQL2k Server to another SQL2k Server. I set up the linked server Connection with the command: EXEC sp_addlinkedserver @server='NEST', @srvproduct='', @provider='SQLOLEDB', @datasrc='ISAG2' The...

IIS 6 and Windows Authentication to SQL Server 2000 - I am running a Windows Server 2003 machine as my web server. I would like to use Windows authentication for connections to my SQL Server 2000 instance on a Windows 2000 server. I've read where mirroring the ASPNET account and password on the web server...

Cannot connect to local sql server 2000 from VB.NET on pc .. - Hi I just installed SQL Server 2000 to run locally on a WinXP Pro SP2 PC. When I run the following VB.NET code: Protected Const SQL_CONNECTION_STRING As String = _ "Server=localhost;" & _ "DataBase=Northwind;" &...

automating server registration - I'm forever running around updating\ change client libraries and aliases on developer machines. Has anyone any idea how I could go about automating this eg User logs in to the network and automatically their server aliases are updated\ corrected with...
   Database Help (Home) -> Connect All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]