?
Solved

How to use Oracle indexes of a linked server?

Posted on 2004-04-16
7
Medium Priority
?
287 Views
Last Modified: 2012-06-21
I have create a linked table to an Oracle server in SQL Server Enterprise Manager.  It connects fine. But the table has 18 millions of rows. So if I query from SQL Server, it takes a lot of time to do that. Is there any way to use or retrieve the indexes of the Oracle table?

In Enterprise Manager -> Linked Servers I see that I have retrieved only tables and views, but no indexes.

I refer to the Oracle table in this way:
select * from LINKEDSERVERNAME..OWNER.TABLE where field01='xx' and field02='yy'

Thanks!

0
Comment
Question by:Cali_Salas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 10843953
You're kind of at the mercy of the OLEDB driver.  SQL Server tries to decide what it can "safely" pass in a query to the remote database.  If it doesn't think it can pass criteria, it will scan all records and apply the "criteria" on the entire resultset that is returned.

Just for giggles, will you try openquery to see if your performance is better?

select * from openquery(linkedservername,'select * from owner.table where field01=xx and field02=yy')

Brett
0
 

Author Comment

by:Cali_Salas
ID: 10844074
Thnaks, is there any way to use OPENQUERY and " ?
I tried to query:

select * from openquery(linkedservername,'select * from owner.table where field01=xx')

[OLE/DB provider returned message: ORA-00904: "xx": invalid identifier]

field01 is a char field

0
 
LVL 34

Accepted Solution

by:
arbert earned 500 total points
ID: 10844147
Sorry, you just double up the single quotes:

select * from openquery(linkedservername,'select * from owner.table where field01=''xx''')
0
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

Author Comment

by:Cali_Salas
ID: 10844169
Ok, the syntax is:
select * from openquery(LINKEDSERVERNAME,'select * from OWNER.TABLE') where field01='xx'

But nothing changes, it takes a lot of time, I just cancel the query.

So... Do we have to think that Linked Servers cannot use indexes and are just a waste of time?
0
 
LVL 34

Expert Comment

by:arbert
ID: 10844201
NO...You just did the same thing that was happening above--you need to include the criteria on the inner select....

Linked servers will use indexes if the criteria is passed to the database in the first place...
0
 

Author Comment

by:Cali_Salas
ID: 10844373
Thanks, arbert, it works well.
0
 
LVL 34

Expert Comment

by:arbert
ID: 10844402
That basically issues a "pass-thru" query to the linked server and passes the statement "as-is".  Like I said before, if you just use the linked server in a query with the 4dot naming convention, SQL Server may or may not pass the criteria to the other server--just depends on if SQL thinks it can pass good criteria or not.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

764 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