P
P
Programep2016-04-25 15:14:15
Oracle
Programep, 2016-04-25 15:14:15

How to reduce the execution time of a t-sql query (optimize) to Oracle?

Good afternoon!
Yes:
MS SQL Server 2012;
Link to Oracle server;
A program that executes similar queries in < 10 seconds.
Required:
Reduce the execution time of the sql query. Tried two options:
1.

SELECT [time],[column1],[column2],[column_N]
from openquery([oracleLink],'SELECT [time],cast([column1] as float) [column1],
cast([column2] as float) [column2],
cast([column_N] as float) [column_N]
FROM [table] WHERE [time] >= ''[time_param]'' 
and [id]=[int_param] and (COALESCE([column1],[column2],[column_N]) is not null)')

2.
SELECT [time],[column1],[column2],[column_N]
from openquery([oracleLink],'SELECT [time],cast([column1] as float) [column1],
cast([column2] as float) [column2],
cast([column_N] as float) [column_N]
FROM [table] WHERE [time] >= ''[time_param]'' 
and [id]=[int_param]') 
where (COALESCE([column1],[column2],[column_N]) is not null)

In the first option, the execution cost is less, but both the first and second options are running > 2 minutes on the first run.
I don't understand why the program works faster.. Tell me, please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Skorzhinsky, 2016-04-27
@AndyKorg

Look at the profiler what exactly is sent by the program to ms sql, and repeat these queries "manually". Not enough information yet for a more complete answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question