The query execution plan is something like this:
SELECT <---- Stream Aggregation <---- Top <----
abw_event.XPKabw_event
Cost: 0% Cost: 0% Cost: 0%
Cost: 100%
MAX(abw_event.event_id)
abw_event.XPKabw_event
ORDERED BACKWARD
I have the latest SQL Server driver (version 2000.85.1117.00) dated
8/4/2004. I think the MDAC get updated with Windows XP Update automatically.
Thanks,
Mehrdad
[quoted text, click to view] "gandalf" wrote:
> What query-plan does the query analyzer show for
> SELECT MAX(event_id) FROM abw_event ?
>
> have you updated the odbc drivers with mdac?
>
>
> >-----Original Message-----
> >I work on a commercial software product that is a
> database application. ODBC
> >database connectivity and MFC record set classes are used
> to access the
> >database. The software supports three types of databases -
> Oracle, Sybase
> >ASA, and SQL Server. One of our clients has a relatively
> big SQL Server 2000
> >SP3a database and they are experience bad performances
> when data is saved to
> >the database. The bottleneck for the bad performance
> appears to be the SELECT
> >MAX(...) statement that is executed against the table
> named abw_event.
> >
> >SELECT MAX(event_id) FROM abw_event;
> >
> >Here is DDL for the table:
> >
> >CREATE TABLE abw_event (
> > event_id int NOT NULL,
> > prev_event_id int NULL,
> > event_type int NOT NULL,
> > on_behalf_of_user int NULL,
> > entered_by int NULL,
> > event_timestamp datetime NOT NULL,
> > event_descr varchar(2000) NULL,
> > event_message varchar(2000) NULL,
> > how_long_to_keep smallint NULL
> >)
> >go
> >
> >ALTER TABLE abw_event
> > ADD CONSTRAINT XPKabw_event PRIMARY KEY
> NONCLUSTERED (event_id)
> >go
> >
> >The abw_event table has 53000 rows in it and its primary
> key is a single
> >column with int data type. The C++ code issues the above
> SELECT MAX(...)
> >command through ODBC function call "SQLExecDirect" that
> takes 15+ seconds to
> >execute.
> >
> >What's interesting is that if I run the same SELECT MAX
> (...) command in the
> >Query Analyzer I get the results instantly. I suspect
> that this bad
> >performance has something to do with ODBC driver.
> >
> >The same SELECT MAX(â?¦) statement executes instantly
> while using Oracle or
> >Sybase ASA databases.
> >
> >I appreciate your feedback.
> >
> >Thanks,
> >Mehrdad
> >
> >.
> >