SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 56981: A simple join might not be not passed to the database, resulting in poor performance

DetailsHotfixAboutRate It

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

Product FamilyProductSystemProduct ReleaseSAS Release
ReportedFixed*ReportedFixed*
SAS SystemBase SASMicrosoft Windows Server 2012 R2 Std9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows Server 2012 Std9.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Enterprise 32 bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Enterprise x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Home Premium 32 bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Home Premium x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Professional 32 bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Professional x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Ultimate 32 bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Windows 7 Ultimate x649.3_M29.4_M39.3 TS1M29.4 TS1M3
64-bit Enabled AIX9.3_M29.4_M39.3 TS1M29.4 TS1M3
64-bit Enabled HP-UX9.3_M29.4_M39.3 TS1M29.4 TS1M3
64-bit Enabled Solaris9.3_M29.4_M39.3 TS1M29.4 TS1M3
HP-UX IPF9.3_M29.4_M39.3 TS1M29.4 TS1M3
Linux9.3_M29.4_M39.3 TS1M29.4 TS1M3
Linux for x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Solaris for x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows Server 2012 R2 Datacenter9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows Server 2012 Datacenter9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows Server 2008 for x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows Server 20089.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8.1 Pro 32-bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8.1 Pro9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8.1 Enterprise x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8 Pro x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8 Pro 32-bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8 Enterprise x649.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft® Windows® for x649.3_M29.4_M39.3 TS1M29.4 TS1M3
z/OS9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows Server 2008 R29.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8.1 Enterprise 32-bit9.3_M29.4_M39.3 TS1M29.4 TS1M3
Microsoft Windows 8 Enterprise 32-bit9.3_M29.4_M39.3 TS1M29.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.