Microsoft KB Archive/900404

= FIX: The results of the query may be returned much slower than you expect when you run a query that includes a GROUP BY statement in SQL Server 2000 =

Article ID: 900404

Article Last Modified on 11/2/2007

-

APPLIES TO


 * Microsoft SQL Server 2000 Enterprise Edition 64-bit
 * Microsoft SQL Server 2000 Desktop Engine (Windows)
 * Microsoft SQL Server 2000 Developer Edition
 * Microsoft SQL Server 2000 Enterprise Edition
 * Microsoft SQL Server 2000 Personal Edition
 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 2000 Workgroup Edition
 * Microsoft SQL Server 2000 Developer Edition

-



BUG #: 474387 (SQL Server 8.0)



''Microsoft distributes Microsoft SQL Server 2000 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2000 fix release.''



SUMMARY
This article describes the following about this hotfix release:
 * The issues that are fixed by the hotfix package
 * The prerequisites for installing the hotfix package
 * Whether you must restart the computer after you install the hotfix package
 * Whether the hotfix package is replaced by any other hotfix package
 * Whether you must make any registry changes
 * The files that are contained in the hotfix package



SYMPTOMS
When you run a query against a view in Microsoft SQL Server 2000, the results of the query may be returned much slower than you expect. You may experience this problem when the following conditions are true:
 * The query that you run includes a GROUP BY statement.
 * The database on which you run the query has the compatibility level set to Database compatibility level 65.

For a list of all publicly released SQL Server 2000 Post-Service Pack 3a hotfixes, click the following article number to view the article in the Microsoft Knowledge Base:

810185 SQL Server 2000 hotfix update for SQL Server 2000 Service Pack 3 and 3a



CAUSE
This problem occurs because when the database compatibility level is set to 65, the GROUP BY statement implies an ORDER BY statement on the columns that the GROUP BY statement affects. If you do not specify an ORDER BY statement in the query, SQL Server implicitly adds the ORDER BY statement. Therefore, SQL Server may select a slower query.



Hotfix information
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next SQL Server 2000 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites
 Microsoft SQL Server 2000 Service Pack 4 (SP4)

For information about how to obtain SQL Server 2000 SP4, click the following article number to view the article in the Microsoft Knowledge Base:

290211 How to obtain the latest SQL Server 2000 service pack



Restart information
You do not have to restart the computer after you apply this hotfix. However, all SQL Server 2000 services are automatically restarted when you apply this hotfix.

Registry information
You do not have to change the registry.

Hotfix file information
This hotfix contains only those files that are required to correct the issues that this article lists. This hotfix may not contain all the files that you must have to fully update a product to the latest build.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

SQL Server 2000 32-bit versions
  Date         Time   Version         Size       File name ---  06-Jun-2005  22:46  8.11.50523.0      239,104  Mssdi98.dll 17-May-2005 01:51  2000.80.1025.0     57,904  Osql.exe 12-Jul-2005 17:24  2000.80.2148.0    430,080  Pfclnt80.dll 17-Jun-2005 00:15                    552,068  Procsyst.sql 17-Jun-2005 00:15                     18,810  Sp4_serv_qfe.sql 08-Jul-2005 01:50  2000.80.2148.0    323,584  Sqlagent.exe 08-Jul-2005 02:51  2000.80.2148.0    118,784  Sqldiag.exe 08-Jul-2005 02:09  2000.80.2148.0    102,400  Sqlfth75.dll 08-Jul-2005 16:07  2000.80.2148.0  9,154,560  Sqlservr.exe

SQL Server 2000 64-bit version
  Date         Time   Version         Size        File name            Platform 08-Jul-2005 16:22  2000.80.2148.0     106,496  Atxcore.dll          IA-64 08-Jul-2005 16:22  2000.80.2148.0     162,816  Axscphst.dll         IA-64 08-Jul-2005 01:37  2000.85.1016.0     200,704  Bcp.exe              IA-64 08-Jul-2005 01:39  2000.80.2148.0      11,264  Cmdwrap.exe          IA-64 08-Jul-2005 16:57  2000.80.2148.0     285,696  Cnvrem.dll           IA-64 08-Jul-2005 16:57  2000.80.2148.0      61,952  Cnvsvc.exe           IA-64 08-Jul-2005 01:37  2000.80.2148.0      59,392  Dbmslpcn.dll         IA-64 08-Jul-2005 03:05  2000.80.2148.0      60,928  Dbmsshrn.dll         IA-64 08-Jul-2005 16:25  2000.80.2148.0      88,576  Distrib.exe          IA-64 08-Jul-2005 16:24  2000.80.2148.0      27,648  Ftsetup.exe          IA-64 08-Jul-2005 16:24  2000.80.2148.0     244,224  Impprov.dll          IA-64 08-Jul-2005 16:29  2000.80.2148.0     258,048  Logread.exe          IA-64 08-Jul-2005 17:58  8.0.2148.0       1,907,200  Msdmeng.dll          IA-64 08-Jul-2005 17:36  8.0.2148.0       5,489,152  Msdmine.dll          IA-64 08-Jul-2005 16:28  2000.80.2148.0     188,416  Msgprox.dll          IA-64 08-Jul-2005 19:16  8.0.2148.0       5,651,456  Msmdcb80.dll         IA-64 08-Jul-2005 17:03  8.0.2148.0       5,961,216  Msmdgd80.dll         IA-64 08-Jul-2005 17:01  8.0.2148.0       5,289,472  Msmdpump.dll         IA-64 08-Jul-2005 19:15  8.0.2148.0       6,492,160  Msmdsrv.exe          IA-64 08-Jul-2005 19:46  8.0.2148.0       6,845,952  Msolap80.dll         IA-64 06-Jun-2005 22:46  8.11.50523.0       758,784  Mssdi98.dll          IA-64 12-May-2005 00:01  1.0.1045.0       2,801,336  Msxmlsql.dll         IA-64 08-Jul-2005 16:23  2000.80.2148.0     151,040  Odsole70.dll         IA-64 08-Jul-2005 01:37  2000.80.2148.0      27,136  Opends60.dll         IA-64 08-Jul-2005 01:41                      19,880  Opends60.lib 08-Jul-2005 16:24  2000.80.2148.0     149,504  Osql.exe             IA-64 08-Jul-2005 16:22  2000.80.2148.0   1,187,840  Pfclnt80.dll         IA-64 08-Jul-2005 16:36  2000.80.2148.0     356,864  Qrdrsvc.exe          IA-64 08-Jul-2005 16:44  2000.80.2148.0   1,033,728  Rdistcom.dll         IA-64 08-Jul-2005 16:28  2000.80.2148.0     132,608  Repldist.dll         IA-64 08-Jul-2005 16:28  2000.80.2148.0     173,056  Repldp.dll           IA-64 08-Jul-2005 16:27  2000.80.2148.0     201,728  Replerrx.dll         IA-64 08-Jul-2005 16:38  2000.80.2148.0     375,296  Replmerg.exe         IA-64 08-Jul-2005 16:32  2000.80.2148.0     537,600  Replprov.dll         IA-64 08-Jul-2005 16:32  2000.80.2148.0     775,168  Replrec.dll          IA-64 08-Jul-2005 16:32  2000.80.2148.0     233,984  Replsync.dll         IA-64 08-Jul-2005 16:39  2000.80.2148.0     654,336  Rinitcom.dll         IA-64 08-Jul-2005 17:07  2000.80.2148.0     161,280  Semmap.dll           IA-64 08-Jul-2005 16:30  2000.80.2148.0     153,088  Semnt.dll            IA-64 08-Jul-2005 16:58  2000.80.2148.0     383,488  Setup.exe            IA-64 08-Jul-2005 16:31  2000.80.2148.0      91,136  Snapshot.exe         IA-64 08-Jul-2005 16:33  2000.80.2148.0      97,792  Spresolv.dll         IA-64 08-Jul-2005 17:08  2000.80.2148.0     269,824  Sqdedev.dll          IA-64 08-Jul-2005 16:32  2000.80.2148.0     171,520  Sqladhlp.exe         IA-64 08-Jul-2005 17:10  2000.80.2148.0      14,848  Sqlagent.dll         IA-64 08-Jul-2005 17:10  2000.80.2148.0   1,061,376  Sqlagent.exe         IA-64 08-Jul-2005 17:12  2000.80.2148.0     103,936  Sqlatxss.dll         IA-64 08-Jul-2005 16:41  2000.80.2148.0      90,112  Sqlboot.dll          IA-64 08-Jul-2005 17:19  2000.80.2148.0   2,275,328  Sqlca.dll            IA-64 08-Jul-2005 17:10  2000.80.2148.0     811,008  Sqlcluster.dll       IA-64 08-Jul-2005 17:13  2000.80.2148.0     132,608  Sqlcmdss.dll         IA-64 08-Jul-2005 16:23  2000.80.2148.0      32,256  Sqlctr80.dll         IA-64 08-Jul-2005 01:43  2000.80.2148.0     812,032  Sqldata.dll          IA-64 08-Jul-2005 01:46                       1,774  Sqldata.lib 08-Jul-2005 16:33  2000.80.2148.0     334,336  Sqldiag.exe          IA-64 12-May-2005 00:01  1.0.48.0         1,428,480  Sqldiscoveryapi.dll  IA-64 08-Jul-2005 16:35  2000.80.2148.0     314,368  Sqldistx.dll         IA-64 08-Jul-2005 17:18  2000.80.2148.0  13,860,352  Sqldmo.dll           IA-64 08-Jul-2005 16:34                      51,712  Sqldumper.exe        IA-64 08-Jul-2005 16:24  2000.80.2148.0     246,784  Sqlfth75.dll         IA-64 08-Jul-2005 16:24  2000.80.2148.0     420,864  Sqlftqry.dll         IA-64 08-Jul-2005 16:39  2000.80.2148.0     251,904  Sqlinitx.dll         IA-64 08-Jul-2005 16:36  2000.80.2148.0     119,296  Sqlisapi.dll         IA-64 08-Jul-2005 17:10  2000.80.2148.0     498,176  Sqlmaint.exe         IA-64 08-Jul-2005 16:21  2000.80.2148.0      23,040  Sqlmap70.dll         IA-64 08-Jul-2005 16:38  2000.80.2148.0     320,000  Sqlmergx.dll         IA-64 08-Jul-2005 16:37  2000.80.2148.0     162,816  Sqlrepss.dll         IA-64 08-Jul-2005 01:42  2000.80.2148.0      29,184  Sqlresld.dll         IA-64 08-Jul-2005 16:23  2000.80.2148.0  30,181,888  Sqlservr.exe         IA-64 08-Jul-2005 16:46  2000.80.2148.0      70,656  Sqlslic.cpl 08-Jul-2005 01:43  2000.80.2148.0     616,960  Sqlsort.dll          IA-64 08-Jul-2005 01:46                       5,814  Sqlsort.lib 08-Jul-2005 17:12  2000.80.2148.0     963,072  Sqlspars.dll         IA-64 08-Jul-2005 16:42  2000.80.2148.0      10,752  Sqlstbss.exe         IA-64 08-Jul-2005 17:17                     822,510  Sqlstp.lib 08-Jul-2005 17:10  2000.80.2148.0     699,392  Sqlsval.dll          IA-64 08-Jul-2005 02:58  2000.80.2148.0     344,064  Sqlsvc.dll           IA-64 08-Jul-2005 02:53  2000.80.2148.0     662,528  Sqlunirl.dll         IA-64 08-Jul-2005 16:39  2000.80.2148.0     120,832  Sqlvdi.dll           IA-64 08-Jul-2005 16:39  2000.80.2148.0     714,240  Sqlvdir.dll          IA-64 08-Jul-2005 16:37  2000.80.2148.0     227,328  Sqsrvres.dll         IA-64 08-Jul-2005 01:37  2000.80.2148.0      55,808  Ssmslpcn.dll         IA-64 08-Jul-2005 16:39  2000.80.2148.0      62,976  Ssmsqlgc.dll         IA-64 08-Jul-2005 03:05  2000.80.2148.0      57,344  Ssmssh70.dll         IA-64 08-Jul-2005 01:38  2000.80.2148.0     259,584  Ssnetlib.dll         IA-64 08-Jul-2005 16:21  2000.80.2148.0      23,040  Ssnmpn70.dll         IA-64 08-Jul-2005 16:39  2000.80.2148.0      64,000  Ssradd.dll           IA-64 08-Jul-2005 16:39  2000.80.2148.0      64,512  Ssravg.dll           IA-64 08-Jul-2005 16:42  2000.80.2148.0      59,392  Ssrmax.dll           IA-64 08-Jul-2005 16:41  2000.80.2148.0      58,880  Ssrmin.dll           IA-64 08-Jul-2005 16:42  2000.80.2148.0     427,008  Svrnetcn.dll         IA-64 08-Jul-2005 16:42  2000.80.2148.0     189,952  Svrnetcn.exe         IA-64 08-Jul-2005 02:51  2000.80.2148.0     142,848  W95scm.dll           IA-64 08-Jul-2005 02:55                       8,260  W95scm.lib 08-Jul-2005 16:42  2000.80.2148.0     162,816  Xpadsi.exe           IA-64 08-Jul-2005 01:39  2000.80.2148.0     125,952  Xplog70.dll          IA-64 08-Jul-2005 16:44  2000.80.2148.0      97,792  Xpqueue.dll          IA-64 08-Jul-2005 16:45  2000.80.2148.0     298,496  Xprepl.dll           IA-64 08-Jul-2005 03:09  2000.80.2148.0     872,960  Xpstar.dll           IA-64 08-Jul-2005 16:43  2000.80.2148.0     196,096  Xpweb70.dll          IA-64 08-Jul-2005 16:24  2000.80.2148.0       3,584  Atxcore.rll 08-Jul-2005 16:26  8.0.2148.0         201,728  Msolap80.rll 08-Jul-2005 16:33  2000.80.2148.0     146,432  Replres.rll 08-Jul-2005 01:40  2000.80.2148.0      34,816  Sqlevn70.rll 08-Jul-2005 16:39  2000.80.2148.0       4,608  Sqlisapi.rll 08-Jul-2005 16:45  2000.80.2148.0       2,560  Sqlstbss.rll 08-Jul-2005 16:42  2000.80.2148.0      61,440  Sqlvdir.rll 08-Jul-2005 01:42  2000.80.2148.0       6,144  Xplog70.rll Note Because of file dependencies, the most recent hotfix or feature that contains these files may also contain additional files.

Installation information
To apply this hotfix, you must add the -T9063 parameter to the SQL Server startup parameters. To view the SQL Server startup parameters, follow these steps:
 * 1) Start SQL Server Enterprise Manager.
 * 2) Expand Microsoft SQL Servers, expand SQL Server Group, right-click a registered SQL Server installation, and then click Properties.
 * 3) On the General tab, click Startup Parameters.
 * 4) To add a parameter, type the parameter in the Parameter box, and then click Add.
 * 5) Click OK to close the Startup Parameters dialog box.



WORKAROUND
To work around this problem, use one of the following methods.

Method 1: Specify the ORDER BY statement in the query
Add the ORDER BY statement to the GROUP BY column in the query in a manner that is similar to the following:

Example view CREATE VIEW VIEW_TEST AS SELECT code, SUM(val) as sum_val FROM TEST GROUP BY code Note In this code example, &quot;code&quot; is the GROUP BY column.

Example query SELECT * FROM VIEW_TEST WHERE code = '0000000100' ORDER BY code -- column &quot;code&quot; is a GROUP BY column.

Method 2: Set the database compatibility level to 80
Set the database compatibility level to 80. To do this, follow these steps:
 * 1) Start SQL Server Enterprise Manager.
 * 2) Expand Microsoft SQL Servers, expand SQL Server Group, expand the computer that is running SQL Server 2000, and then expand Databases.
 * 3) Right-click the database that you want to modify, and then click Properties.
 * 4) Click the Options tab.
 * 5) In the Level list, click Database compatibility level 80, and then click OK.

For more information about database compatibility between SQL Server 2000 and SQL Server 6.5, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/aa215536(SQL.80).aspx



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
For more information about the naming schema for SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:

822499 New naming schema for Microsoft SQL Server software update packages

For more information about the terminology that Microsoft uses when Microsoft corrects software after it is released, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kbbug kbfix kbqfe kbhotfixserver KB900404

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.