Problem Note 56981: A simple join might not be not passed to the database, resulting in poor performance
When you join a SAS® table to a database management system (DBMS) table on a single column, the join might be converted to a WHERE clause that contains an IN condition, and a list of values from the SAS table is passed to the DBMS so that the query resolves in the DBMS.
However, under some circumstances, if the SELECT clause contains a CASE expression and an ALIAS, the list of values might not be passed. In this case, the DBMS table is pulled back to SAS, resulting in poor performance.
Here is an example.
options sastrace=',,,d' sastraceloc=saslog nostsuffix;
proc sql;
create table work.table as
select oracle_table.ora_var1,
case when oracle_table.ora_var2="x" then ""
else oracle_table.ora_var2
end as newvar
from work.sas_table
inner join dbms.oracle_table on sas_table.sas_lookup=oracle_table.ora_lookup;
quit;
Here, SASTRACE= shows that a SELECT * was executed:
ORACLE_10: Prepared: on connection 0
SELECT * FROM mySchema.ORACLE_TABLE
ORACLE_13: Executed: on connection 0
SELECT statement ORACLE_10
To work around the issue, remove the AS alias NEWVAR from the original query. SASTRACE shows that a WHERE clause is passed with the IN condition:
ORACLE_18: Prepared: on connection 0
SELECT "ORA_LOOKUP", "ORA_VAR1", "ORA_VAR2" FROM mySchema.ORACLE_TABLE WHERE ( ("ORA_LOOKUP" IN ( '1' , '2' , '3' ) ) )
ORACLE_19: Executed: on connection 0
SELECT statement ORACLE_18
Click the Hot Fix tab in this note to access the hot fix for this issue.
Operating System and Release Information
SAS System | Base SAS | Microsoft Windows Server 2012 R2 Std | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows Server 2012 Std | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Enterprise 32 bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Enterprise x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Home Premium 32 bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Home Premium x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Professional 32 bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Professional x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Ultimate 32 bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Windows 7 Ultimate x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
64-bit Enabled AIX | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
64-bit Enabled HP-UX | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
64-bit Enabled Solaris | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
HP-UX IPF | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Linux | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Linux for x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Solaris for x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows Server 2012 R2 Datacenter | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows Server 2012 Datacenter | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows Server 2008 for x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows Server 2008 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8.1 Pro 32-bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8.1 Pro | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8.1 Enterprise x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8 Pro x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8 Pro 32-bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8 Enterprise x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft® Windows® for x64 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
z/OS | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows Server 2008 R2 | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8.1 Enterprise 32-bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
Microsoft Windows 8 Enterprise 32-bit | 9.3_M2 | 9.4_M3 | 9.3 TS1M2 | 9.4 TS1M3 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Problem Note |
Priority: | high |
Date Modified: | 2015-12-15 12:10:19 |
Date Created: | 2015-11-02 06:32:12 |