Re: query from sql server linked server slow

From: Kellyn Pot'Vin-Gorman <dbakevlar_at_gmail.com>
Date: Wed, 26 Dec 2018 11:06:13 -0800
Message-ID: <CAN6wuX0iVTViFEwFzEuvsV18LAkhMe2ySwUpb4U_RihAU_KVPg_at_mail.gmail.com>



Hi Bob,
Although I don't know what version of MSSQL, I'll assume a newer version...:)

From the SSMS side, set up an extended event, (tracing, to translate) and track down what the difference is. Identify plan migration due to links, views and distributed query. From there, once identified, lock the plan on the SQL Server side to ensure the most optimal plan.

https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events?view=sql-server-2017

Kellyn

On Wed, Dec 26, 2018 at 10:47 AM Stauffer, Bob <RStauffer_at_fult.com> wrote:

> Hi all,
>
>
>
> Oracle 12.2, Red Hat 7, SQL Server 2012
>
>
>
> I know, this isn’t a SQL Server forum, but I’m running out of ideas on how
> to troubleshoot the following. When running a specific query from SQL
> Developer or SQLPlus on my Windows 7 PC in and Oracle database, that query
> is relatively fast. It returns 16 records in less than 20 seconds. But
> when run in a SQL Server instance using SSMS and using OPENQUERYlinked
> server, it never completes – it will actually run for days if we don’t kill
> it. I’ve tracked it down to a difference in execution plans on the Oracle
> database side. Of course, when run in the Oracle database using SQL
> Developer, it generates an efficient execution plan. But when run via
> OPENQUERY/linked server in SQL Server, the execution plan in Oracle is
> horrendous. I’ve tried loading a better plan for the query using
> dbms_spm.alter_sql_plan_baseline, etc., but it ignores the new plan. And
> I’ve tried creating a view for the query, but that makes no difference
> either.
>
>
>
> First, can anyone explain why 2 different execution plans are used in the
> Oracle db for the same query? Supposedly OPENQUERY/linked server are just
> submitting the query to Oracle for optimization without doing any
> “pre-optimization”. And any thoughts on how I can troubleshoot/figure out
> how to fix or get around the problem?
>
>
>
> Thanks much.
>
>
>
> *Bob Stauffer*
>
> rstauffer_at_fult.com
>
>
> ***CONFIDENTIALITY NOTICE***This email contains confidential information
> which may also be legally privileged and which is intended only for the use
> of the recipient(s) named above. If you are not the intended recipient, you
> are hereby notified that forwarding or copying of this email, or the taking
> of any action in reliance on its contents, may be strictly prohibited. If
> you have received this email in error, please notify us immediately by
> reply email and delete this message from your inbox. Thank you. E-Mail Opt
> Out Notice: This e-mail message may include an advertisement. You have the
> right to request that we not send future advertisements to you at this
> e-mail address. If you prefer not to receive future advertisements from us
> at this e-mail address, please access the following url
> http://www.optoutffc.com/ Fulton Financial Corporation, P.O. Box 4887,
> Lancaster, Pa. 17604
>

-- 


[image: Kellyn Pot'Vin on about.me]

*Kellyn Pot'Vin-Gorman*
DBAKevlar Blog <http://dbakevlar.com>
President Denver SQL Server User Group <http://denversql.org/>
about.me/dbakevlar

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Dec 26 2018 - 20:06:13 CET

Original text of this message