Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Poor performance of linked oracle server

Posted on 2004-09-29
6
Medium Priority
?
344 Views
Last Modified: 2012-06-27
Hi there

Am wondering if anyone may able to offer any suggestions for a problem I'm having with a SQL linked servers.

I've got a SQL server running which has a linked server to an oracle database.  I'm finding that a query run via the SQL server takes signifigantly longer than if I run the same query with a straight ODBC connection. (4 seconds on ODBC vs 4 minutes 50 seconds with a linked server.)

Any ideas about what could be causing the lag?

Regards


Marty
0
Comment
Question by:martypitt
6 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 12187298
Maybe--can you post the query.  What happens if you use OPENQUERY against the server instead of using the linked server directly?

select * from openquery(yourlinkedservername,'thesql statement')


When you use a linked server, SQL Server will pass the criteria to the server that it thinks it can "safely" pass.  If it doesn't know how to pass a where clause or function, it will select all the records from the linked server and perform the criteria on the local SQL Server instead.  When you use openquery, a passthru query is actually passed.

Brett
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 12187704

With ODBC Connection U get only partial data(If ur data has alot of rows)

But when u use it with penquery from a linked server, SQL Server would try to get all rows into a temp Table in Tmpdb, for that reason it would took along time.

If not the problem would be Client Connection Drivers.

Or ur linked Server Oracle Db Connection Provider could be different then the ODBC Driver.


Melih SARICA

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 12188053
as Arbert indicates, the problem might be the "query" so that SQL server cannot optimize it.

Sample Query with probable bad performance:
select * from OracleServer..Schema.table1
, OracleServer.Schema.Table2
where table1.pk = table2.pk

Sample query with best performance:
select * from OpenQuery ( OracleServer,
' select col1, col2, .... from Schema.table1
, Schema.Table2
where table1.pk = table2.pk
' )

The reason is explained by non_zero: in the first case, the join is performed on the local Sql server, thus all the data from both tables needs to be transferred to the sql server.
The second sample passes the sql to the oracle box, the join is performed on the oracle box, and only the results are send back

Cheers

CHeers
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 10

Expert Comment

by:imrancs
ID: 12192471
hmmm, good information for me as well
0
 
LVL 34

Expert Comment

by:arbert
ID: 12192485
Always --especially with linked servers--you finally figure out some workarounds for their poor performance...
0
 
LVL 34

Expert Comment

by:arbert
ID: 12195625
So what did you find the problem was?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question