Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Please help optimize this web interface

Posted on 2009-07-08
7
Medium Priority
?
291 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 200 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 1800 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
What we learned in Webroot's webinar on multi-vector protection.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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