Re: SELECT MAX(...) performance in SQL Server/ODBC
From: Mehrdad (Mehrdad_at_discussions.microsoft.com)
Date: 10/20/04
- Next message: Cindy Winegarden: "Re: MDAC 2.7 SP1 Refresh and FoxPro"
- Previous message: Youri Siaens: "RE: MDAC 2.7 SP1 Refresh and FoxPro"
- In reply to: Brannon Jones: "Re: SELECT MAX(...) performance in SQL Server/ODBC"
- Next in thread: Mehrdad: "Re: SELECT MAX(...) performance in SQL Server/ODBC"
- Reply: Mehrdad: "Re: SELECT MAX(...) performance in SQL Server/ODBC"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 07:43:02 -0700
Thanks Brannon for the suggestions.
I tried the Profiler and compared the results and execution plans in the two
cases:
(1) executing the query from SQL Analyzer
(2) executing the query from C++ code by calling SQLExecDirect.
I found no difference between the two profiles. What I noticed was that it
takes 15 seconds to see any activity in the profiler. So I kind of think that
it gets stuck in either MFC or ODBC Driver. I noticed that in our code we are
using the function SQLAllocStmt which is a deprecated ODBC function. I am
going to replace that function call with its (supported) equivalent
SQLAllocHandle to see if that makes a difference.
"Brannon Jones" wrote:
> Well Query Analyzer uses the ODBC driver to send the command to the server,
> so it's not necessarily a problem with the driver, but maybe how it's being
> used (I'm pretty sure that Query Analyzer doesn't use the MFC Database
> classes).
>
> Have you tried using SQL Profiler to profile the events on the server?
>
> Brannon
>
> "Mehrdad" <Mehrdad@discussions.microsoft.com> wrote in message
> news:987B03D5-5C56-47D1-8725-A590EFEBA0FA@microsoft.com...
> > 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
> >
>
>
>
- Next message: Cindy Winegarden: "Re: MDAC 2.7 SP1 Refresh and FoxPro"
- Previous message: Youri Siaens: "RE: MDAC 2.7 SP1 Refresh and FoxPro"
- In reply to: Brannon Jones: "Re: SELECT MAX(...) performance in SQL Server/ODBC"
- Next in thread: Mehrdad: "Re: SELECT MAX(...) performance in SQL Server/ODBC"
- Reply: Mehrdad: "Re: SELECT MAX(...) performance in SQL Server/ODBC"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|