Solved

Please help optimize this web interface

Posted on 2009-07-08
7
288 Views
Last Modified: 2012-06-27
So we've built this web-based application for our Customer Service people to search a specific database table and retreive order information for our customers. The interface consists of an .ASP page that dynamically builds and submits a query and then displays the results. The problem is that it sometimes takes a couple of minutes to return the results and sometimes the thing just times out and throws an error. (Then they tell me about it, that's the real problem.)  Anyway I'd like some help trying to optimize the performance of this interface. I know enough to be dangerous, but not quite enough to be completely on top of the DB performance.

The table has 6.7 million records with the following columns:
OrderID            (primary key and ID, int)
PartnersID            (int)
PartnersOrderID      (varchar 255)
OrderDate            (varchar 255)
ProductCode            (int)
OrderType            (char 1)
Status            (varchar 255)
CreateDate            (datetime)
ProcessDate            (datetime)
CancelDate            (smalldatetime)
FirstName            (varchar 255)
LastName            (varchar 255)
Address1            (varchar 255)
Address2            (varchar 255)
City            (varchar 255)
State            (varchar 255)
ZipCode            (varchar 255)

The fields on the form which go into the query can be:
FirstName
LastName
ZipCode
PartnersOrderID
OrderID
ProductCode
PartnerID
OrderType
StartDate
EndDate
Status

When the .ASP builds the query it has to use wildcard characters around a lot of the fields. For instance if someone searches for "Jane" it needs to match "Mary Jane" and "Janessa". Therefore looking for "%jane%" slows the thing down significantly, obviously, but I dont' know how else to make the tool useful because the public-at-large can't be counted on to be helpful enough to know their own name, unfortunately.

The people we've got supporting our servers suggest that it's slow because we're always submitting queries instead of stored procedures, but I don't see how to put all of this into a stored procedure when all of the fields aren't populated.

So I'm now thinking that I could fool around with secondary keys or something.

Anybody got any bright ideas?



The statistics of the SQL server are:
Product Version: "8.00.2039"
Product Level: "SP4"
Edition: "Enterprise Edition"
Engine Edition: "3"
EngineEditionText: "Enterprise . . ."
0
Comment
Question by:Rossamino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 50 total points
ID: 24808765
you will have to investigate about the possible WHERE clauses that the application builds, and make sure they are all supported by proper indexes.
check out SARG (searchable arguments) and indexing...
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 450 total points
ID: 24810612
>>Therefore looking for "%jane%" slows the thing down significantly<<
That is because it has to to a table scan.  That is why it is taking so long.  You may want to read up on Full-Text search, this will give you the performance you need, but you do need to set it up correctly.
0
 

Author Comment

by:Rossamino
ID: 24813785
So I should add indexes for the integer and date fields and implement full-text searching for the character data? Anything else?
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24814235
>>So I should add indexes for the integer and date fields and implement full-text searching for the character data? <<
No, I did not say that.  I said you should read up on Full-Text search.  After you have done that then you may decide that it is the approach you want to take.  But the decision should not be taken lightly as there is more then just a code change. It is not trivial.
0
 

Author Comment

by:Rossamino
ID: 24816187
Oh, well I've created the Full Text Catalog and set the one table to Populate tonight at 1:00am. I don't really see any downside.  I hope there's nothing I'm missing.

I'm looking at the MSDN overview of how to write a full text query and the syntax is a bit puzzling.  If I wanted to rewrite:
select * from OrderData where firstname like '%jane%'
it should look like:
select * from OrderData where contains(firstname, 'jane') ?
The overview page has some characters that aren't rendering properly on the page so I can't quite make it out.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24816403
>>I hope there's nothing I'm missing.<<
That new or modified data has to be managed in one of three ways:
1. Added Manually.
2. Added on schedule.
3. Added in the background

In all three cases it is not updated immediately.

>>I'm looking at the MSDN overview of how to write a full text query and the syntax is a bit puzzling. <<
Provided the name you are looking for is jane then yes the syntax is:
select * from OrderData where firstname like '%jane%'
SELECT  *
FROM    OrderData
WHERE   CONTAINS(firstname, 'jane' )

Or to look in all Full-Text columns
SELECT  *
FROM    OrderData
WHERE   CONTAINS(*, 'jane' )

This will find instancees of "Jane" or "Mary Jane" or "Jane Elizabeth"

You can also do the following to search for all names starting with "jan":
SELECT  *
FROM    OrderData
WHERE   CONTAINS(*, '"jan*"' )

What you cannot do with Full-Text Search is search for "jane" to find "maryjane" (one word).  In other words you cannot do this:
SELECT  *
FROM    OrderData
WHERE   CONTAINS(*, '"*jan"' )
0
 

Author Closing Comment

by:Rossamino
ID: 31601340
Thanks a lot and I'm sure the CSR's will thank you as well.
0

Featured Post

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question