SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 66707: An incorrect query might be sent to a database when two like-named variables are being selected and grouped on, resulting in slow performance

DetailsHotfixAboutRate It

A performance issue might occur when you query a database management system (DBMS) table via a LIBNAME engine and the following conditions exist in your SQL procedure query:

  • You are selecting two like-named variables where the shorter of the two named variables is listed first.
  • You are assigning a label to both variables.
  • You are summarizing a third variable.
  • The two like-named variables appear on the GROUP BY clause.
  • The second variable is not being renamed.
  • The two like-named variables are both from the same table listed on the FROM clause.

The following code illustrates one case that might produce slow performance:

proc sql;
create table results as
select x label='the 1st variable', x1 label='the 2nd variable', count(y) as cnt
from dblib.test
group by x,x1;
quit;

The slow performance is caused by an incorrect query being passed to the database where the first variable is listed twice in the GROUP BY clause rather than the two different variables appearing in the GROUP BY clause. This behavior results in a database error because most databases require that variables that appear in a SELECT clause must also appear in the GROUP BY clause when the query includes a summary function. Because of the error, SAS® software might attempt to pass a second query in which it removes the summarization. Instead of the DBMS performing the processing, SAS reads in the DBMS table and the summarization in performed by SAS. This behavior often results in slower performance due to the extra data being read into SAS.

To work around the issue, remove the label modifiers from the query and add them in a subsequent step.

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 SASSolaris for x649.4_M69.4 TS1M6
Linux for x649.4_M69.4 TS1M6
HP-UX IPF9.4_M69.4 TS1M6
64-bit Enabled Solaris9.4_M69.4 TS1M6
64-bit Enabled AIX9.4_M69.4 TS1M6
Windows 7 Ultimate x649.4_M69.4 TS1M6
Windows 7 Ultimate 32 bit9.4_M69.4 TS1M6
Windows 7 Professional x649.4_M69.4 TS1M6
Windows 7 Professional 32 bit9.4_M69.4 TS1M6
Windows 7 Home Premium x649.4_M69.4 TS1M6
Windows 7 Home Premium 32 bit9.4_M69.4 TS1M6
Windows 7 Enterprise x649.4_M69.4 TS1M6
Windows 7 Enterprise 32 bit9.4_M69.4 TS1M6
Microsoft Windows Server 20199.4_M69.4 TS1M6
Microsoft Windows Server 20169.4_M69.4 TS1M6
Microsoft Windows Server 2012 Std9.4_M69.4 TS1M6
Microsoft Windows Server 2012 R2 Std9.4_M69.4 TS1M6
Microsoft Windows Server 2012 R2 Datacenter9.4_M69.4 TS1M6
Microsoft Windows Server 2012 Datacenter9.4_M69.4 TS1M6
Microsoft Windows Server 2008 for x649.4_M69.4 TS1M6
Microsoft Windows Server 2008 R29.4_M69.4 TS1M6
Microsoft Windows Server 20089.4_M69.4 TS1M6
Microsoft Windows 109.4_M69.4 TS1M6
Microsoft Windows 8.1 Pro x649.4_M69.4 TS1M6
Microsoft Windows 8.1 Pro 32-bit9.4_M69.4 TS1M6
Microsoft Windows 8.1 Enterprise x649.4_M69.4 TS1M6
Microsoft Windows 8.1 Enterprise 32-bit9.4_M69.4 TS1M6
Microsoft Windows 8 Pro x649.4_M69.4 TS1M6
Microsoft Windows 8 Pro 32-bit9.4_M69.4 TS1M6
Microsoft Windows 8 Enterprise x649.4_M69.4 TS1M6
Microsoft Windows 8 Enterprise 32-bit9.4_M69.4 TS1M6
Microsoft® Windows® for x649.4_M69.4 TS1M6
z/OS 64-bit9.4_M69.4 TS1M6
z/OS9.4_M69.4 TS1M6
* 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.