Re: performance of 2 queries
From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 10/28/04
- Next message: Elmo Watson: "Re: enumerate MSDE instances on Network"
- Previous message: Steve Ricketts: "REPOST: One Web Service updates SQL, the other can't"
- In reply to: David: "performance of 2 queries"
- Next in thread: Mark J. McGinty: "Re: performance of 2 queries"
- Reply: Mark J. McGinty: "Re: performance of 2 queries"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 28 Oct 2004 11:08:25 -0400
Looping through an entire resultset and testing each value is by far the
least efficient solution.
The best solution, in my opinion, is creating a stored procedure and passing
the search criteria to the procedure.
-- http://www.aspfaq.com/ (Reverse address to reply.) "David" <Obsession_2001@hot-NOSPAM-mail.com> wrote in message news:418108aa$0$25839$ba620e4c@news.skynet.be... > Hi, > > I have a question about the performance of 2 queries (used in VB6 > [DataEnvironment] application / CTI integration) > > When a call arrives I look up the phonenumber in an sql server 2000 SP3 > database table with about 1500-3000 records (3 fields: > PrimKey,CompanyName,Tel) > This has to happen as fast as possible ofcourse. I have 2 solutions but I > don't know which would be the most efficient. > I've looked at the profiler utility and from what I can tell the first one > uses a disconnected recordset because I don't see anything happen in > profiler. However from what I can see in my code I never created this > recordset disconnected. I don't even know exactly how I would create such a > recordset. > The 2nd solution does generate some activity in profiler, sometimes alot, > depending on how many clients are using the application (max 10 > conncurrently) > > > Solution #1 > Dim szCallName As String > Data1.rssqlLookupCompanyWithTel.MoveFirst > Do While Not Data1.rssqlLookupCompanyWithTel.EOF > If Trim(Data1.rssqlLookupCompanyWithTel("tel")) = CallerID Then > szCallName = Data1.rssqlLookupCompanyWithTel("CompanyName") > Data1.rssqlLookupCompanyWithTel.MoveNext > Loop > > Solution #2 > Dim szCallName As String > Data1.rssqlLookupCompanyWithTel.Close > Data1.rssqlLookupCompanyWithTel.Open "SELECT CompanyName FROM > AllTelephoneNumbers WHERE Tel = '" & CallerID & "'" > If Data1.rssqlLookupCompanyWithTel.EOF <> True Then szCallName = > Trim(Data1.rssqlLookupCompanyWithTel("CompanyName")) > > > Which solution do you think is the best? Or is there another better > solution? > In the VB6 dataenvironment I can choose between the following: Client or > Server side cursor. Which one do I use in this case? The LockType is > readonly. Cache Size=100 > > > thank you, > > > David > >
- Next message: Elmo Watson: "Re: enumerate MSDE instances on Network"
- Previous message: Steve Ricketts: "REPOST: One Web Service updates SQL, the other can't"
- In reply to: David: "performance of 2 queries"
- Next in thread: Mark J. McGinty: "Re: performance of 2 queries"
- Reply: Mark J. McGinty: "Re: performance of 2 queries"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading