Different execution plan using param with Direct and OraQuery
Posted: Fri 10 Jun 2016 15:26
Hi,
I have a sql statement that I ran with OraQuery on a Direct connection that took forever to run. I knew that it should run under 1 second not so I investigated.
Info: Windows 10 64bit, Oracle 12c, Oracle 12c client, Seattle, ODAC 9.7.24
Statment executed fine with parameters on:
SQL Developer with both basic and tns connections
FireDac
OraQuery & SmartQuery on TNS connection
OraQuery & SmartQuery on Direct connection - values instead of parameters
OraSession.ExecSQL(); with TNS and Direct connection
OraSQL with TNS and Direct connection
Statment did not execute as it should when using:
OraQuery/SmartQuery with Direct connection using parameters
The query has two parameters and both field types are NUMBER(15,0)
I've tried multiple combination of settings for ParamType, DataType and value.
I've also tried (I think, the correct native way):
OraNum1 := TOraNumber.Create;
OraNum1.AsLargeInt := 29992348;
x.ParamByName('param1').ParamType := ptInput;
x.ParamByName('param1').DataType := TFieldType(Ora.ftNumber);
x.ParamByName('param1').AsNumber := OraNum1;
..with same result
But when I remove the parameters from the statement and replace with values it runs < 1 sec. with optimal execution plan.
So I would think that the problem is with using parameters in TOraQuery - In this case it makes the database choose the wrong execution path.
Am I doing it wrong or is this some kind of a bug?
-Arni Thor
I have a sql statement that I ran with OraQuery on a Direct connection that took forever to run. I knew that it should run under 1 second not so I investigated.
Info: Windows 10 64bit, Oracle 12c, Oracle 12c client, Seattle, ODAC 9.7.24
Statment executed fine with parameters on:
SQL Developer with both basic and tns connections
FireDac
OraQuery & SmartQuery on TNS connection
OraQuery & SmartQuery on Direct connection - values instead of parameters
OraSession.ExecSQL(); with TNS and Direct connection
OraSQL with TNS and Direct connection
Statment did not execute as it should when using:
OraQuery/SmartQuery with Direct connection using parameters
The query has two parameters and both field types are NUMBER(15,0)
I've tried multiple combination of settings for ParamType, DataType and value.
I've also tried (I think, the correct native way):
OraNum1 := TOraNumber.Create;
OraNum1.AsLargeInt := 29992348;
x.ParamByName('param1').ParamType := ptInput;
x.ParamByName('param1').DataType := TFieldType(Ora.ftNumber);
x.ParamByName('param1').AsNumber := OraNum1;
..with same result
But when I remove the parameters from the statement and replace with values it runs < 1 sec. with optimal execution plan.
So I would think that the problem is with using parameters in TOraQuery - In this case it makes the database choose the wrong execution path.
Am I doing it wrong or is this some kind of a bug?
-Arni Thor