Connecting Tech Pros Worldwide Forums | Help | Site Map

Slow Query causing application problems

dcharnigo's Avatar
Newbie
 
Join Date: Feb 2007
Location: Ohio
Posts: 20
#1: Jul 29 '08
Hi All,

I am running a sql query from a web application. The web application timeout is set to 30 seconds and really should not be increased. I am running a very specific query [select * from table where guid = 'guid']. The table currently has 1 million rows and is growing everyday. The table is indexed but not on the guid field. Other queries return quickly but since this query is for only a single record based on the unique guid it is taking on average 45 seconds to return (when run in the studio) and thus the web application times out.

Is there a way I can speed this up? I don't think adding an index on the guid would be very smart but then again I am far from expert.

Thanks,

Dan

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 29 '08

re: Slow Query causing application problems


If you are using the field as filter condition most of the time, you might want create an index for it.

-- CK
Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 788
#3: Jul 30 '08

re: Slow Query causing application problems


The query is as simple as it gets so you won't be able to gain any performance increase by re-designing the query.
There are only 2 options that I can see
1) Index the guid.
The whole point of indexing is to speed up slow queries.
So why would it not be smart to use them?
If there is a lot of inserting and deleting of records then you need to be careul
about how many indexes you put on a table, but otherwise......within reason...

2) Make the dataset smaller.
dcharnigo's Avatar
Newbie
 
Join Date: Feb 2007
Location: Ohio
Posts: 20
#4: Jul 31 '08

re: Slow Query causing application problems


Oh &^%$$%^^ If you notice in the first post I said the query was "where guid = guid" the actual query was "where guid like 'guid'", i changed it to an equal sign and it returns in a half second.
Reply