Slow Query causing application problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dcharnigo
    New Member
    • Feb 2007
    • 20

    Slow Query causing application problems

    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
    Recognized Expert Specialist
    • Jun 2007
    • 2878

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

    -- CK

    Comment

    • Delerna
      Recognized Expert Top Contributor
      • Jan 2008
      • 1134

      #3
      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.

      Comment

      • dcharnigo
        New Member
        • Feb 2007
        • 20

        #4
        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.

        Comment

        Working...