Web Images Videos Maps News Groups Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Performance Issue
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chris  
View profile  
 More options Sep 16 2006, 6:36 am
Newsgroups: microsoft.public.sqlserver.programming
From: Chris <Ch...@discussions.microsoft.com>
Date: Fri, 15 Sep 2006 13:36:02 -0700
Local: Sat, Sep 16 2006 6:36 am
Subject: Performance Issue

SQL2000 Std Ed.

Customers table 4 million records

Users search by phone# - during periods of heavy use the cpu will peg to
100% and searches will take 20+ seconds.

Here's the facts:
- where cluase uses '... where fPhone like @TelNo '
- No blocking, stored proc uses (nolock) isol. level.
- Query plan uses index on fPhone field - total cost 1.895 and less w/ the
more numbers entered in search.
- No to < 5% fragmentation - rebuilt when at 5% or greater
- Run profiler - see duration at 20000 milliseconds (rules out the network -
def. db)
- For long running spid - run sp_lock and see TAB lock on customers table

Was troubleshooting w/ user - user app in asp connecting w/ ado over oledb -
I was witnessing user spid taking 20+ seconds, I would grab exact same query
in profiler and run in Query Analyzer - it would take 1 seconds in QA - user
runs again 20 seconds, I run in QA - 1 to 2 seconds. User runs same again -
20 seconds - data cache not speeding things up.

I am assuming the app is getting stuck on a procedure cache that somehow
ignores the index on fPhone and does table scan - searches with 2 or 3
numbers do table scan - searches where all 7 numbers entered - index used.
Perhaps 1 user enters 3 numbers to search on - table scan query plan saved in
cache - next user searches by 7 numbers - db uses query plan w/ table scan.

Is this table lock escalation - is that common during periods of high
activity?

Any ideas how to combat?

Thanks,
Chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sabin  
View profile  
 More options Sep 16 2006, 7:01 am
Newsgroups: microsoft.public.sqlserver.programming
From: Simon Sabin <SimonSa...@noemail.noemail>
Date: Fri, 15 Sep 2006 21:01:42 +0000 (UTC)
Local: Sat, Sep 16 2006 7:01 am
Subject: Re: Performance Issue
Hello Chris,

You shouldn't be getting a table lock. Can you change the SP to use WITH
RECOMPILE?

What is the isolation level that is being used?

Is there any process updating the customer table?

How many reads/writes are occuring (look in profiler)

Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim Underwood  
View profile  
 More options Sep 16 2006, 7:12 am
Newsgroups: microsoft.public.sqlserver.programming
From: "Jim Underwood" <james.underwoodATfallonclinic.com>
Date: Fri, 15 Sep 2006 17:12:10 -0400
Local: Sat, Sep 16 2006 7:12 am
Subject: Re: Performance Issue
where fPhone like @TelNo

is @TelNo prefixed or suffixed with %?

if you prefix the search string with % then you can't really use an index.
If you append the % then you can, but the fewer values entered the less
efficient it is to use the index.

Is it really necessary to search on part of a phone number?  Would a use
ever not know the entire phone number?

It would likely be faster to do

where fPhone = @TelNo

Also, you could have a problem with parameter sniffing, but I'll let those
more knowledgeable explain that.

"Chris" <Ch...@discussions.microsoft.com> wrote in message

news:0D4EA01E-209A-4654-BF81-8B85BAF147CF@microsoft.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris  
View profile  
 More options Sep 16 2006, 8:59 am
Newsgroups: microsoft.public.sqlserver.programming
From: Chris <Ch...@discussions.microsoft.com>
Date: Fri, 15 Sep 2006 15:59:02 -0700
Local: Sat, Sep 16 2006 8:59 am
Subject: RE: Performance Issue

My suspicions were correct. User running tel search, taking 15 seconds.
Found TAB lock on cust table. Ran same query in QA - 1 second.

Executed dbcc freeprocache

User query now executing in 1 second response time.

How is a bad plan getting stuck in cache?

Is this a statistics issue or somehting? How do I rebuild/refresh stats?
Index getting rebuilt when > 5% fragmentation.

Thanks,
Chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew J. Kelly  
View profile  
 More options Sep 16 2006, 10:34 am
Newsgroups: microsoft.public.sqlserver.programming
From: "Andrew J. Kelly" <sqlmvpnooos...@shadhawk.com>
Date: Fri, 15 Sep 2006 20:34:08 -0400
Local: Sat, Sep 16 2006 10:34 am
Subject: Re: Performance Issue
SQL Server doesn't know it is a "Bad" plan or it wouldn't have generated it
in the first place. Plans are supposed to be in the cache. This and the
associated articles will go a long way towards defining how that all works
and hopefully answer your questions in that regard.
http://msdn2.microsoft.com/en-us/library/ms181055.aspx

--
Andrew J. Kelly SQL MVP

"Chris" <Ch...@discussions.microsoft.com> wrote in message

news:E7254A17-6CA1-43AD-B375-15C9F38F5212@microsoft.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Linwood  
View profile  
 More options Sep 17 2006, 12:01 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Greg Linwood" <g_linw...@hotmail.com>
Date: Sun, 17 Sep 2006 12:01:16 +1000
Local: Sun, Sep 17 2006 12:01 pm
Subject: Re: Performance Issue
Hi Chris

I'm wondering what you mean by:

>- Run profiler - see duration at 20000 milliseconds (rules out the
>network - def. db)<

Duration takes into account network time, so this metric alone doesn't rule
out the network, although this also isn't the first place I'd look.

You also said that the query is using an index on fPhone, but that a TAB
lock is being taken. Whilst this can occur, you really need to provide more
information to make these observations meaningful (eg, is the TAB lock an
intent lock etc).

Any chance you can post the execution plan & sp_help output for the table?

Also - are you using a LIKE predicate because of the possibilities of area
codes prefixing the ph no? I had an idea whilst reading your post which
might work for you.. Because area codes always prefix a ph no, the front
part of the number is variable (depending on how the user inputs their ph
no). But the end of the ph number should always be the same, right? If this
assumption is correct, it should be possible to store the number in reverse
(also removing whitepsaces) in a second column & index that column. Then, to
query the column, you flip your numbers around (& remove whitepsace) and
compare this value against the index, using LIKE & you should get vastly
improved performance from a range scan.. Just an idea..

Regards,
Greg Linwood
SQL Server MVP
http://blogs.sqlserver.org.au/blogs/greg_linwood

"Chris" <Ch...@discussions.microsoft.com> wrote in message

news:0D4EA01E-209A-4654-BF81-8B85BAF147CF@microsoft.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Linwood  
View profile  
 More options Sep 17 2006, 1:33 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Greg Linwood" <g_linw...@hotmail.com>
Date: Sun, 17 Sep 2006 13:33:30 +1000
Local: Sun, Sep 17 2006 1:33 pm
Subject: Re: Performance Issue
Hi Chris

I created a sample script on my blog to demo how storing a reversed version
of each phone number in a seperate column can avoid your wildcard search,
allowing lightening fast index seeks instead of the table scan you're
currently doing.

If you're interested in checking it out, it's here:
http://blogs.sqlserver.org.au/blogs/greg_linwood/archive/2006/09/17/3...

HTH

Regards,
Greg Linwood
SQL Server MVP
http://blogs.sqlserver.org.au/blogs/greg_linwood

"Greg Linwood" <g_linw...@hotmail.com> wrote in message

news:uk9nr0f2GHA.4116@TK2MSFTNGP02.phx.gbl...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim  
View profile  
 More options Sep 20 2006, 2:56 am
Newsgroups: microsoft.public.sqlserver.programming
From: "Jim" <Jim.Muek...@wellsfargo.com>
Date: 19 Sep 2006 09:56:50 -0700
Local: Wed, Sep 20 2006 2:56 am
Subject: Performance Issue
Hi,

         I need to remove duplicate rows from a table.   The process
that I am using, which is shown below, is extremely slow - it takes
about 30 minutes to process 2000 rows.    Can anyone point out any
obvious reasons that my technique is slow? - or perhaps propose a
better technique?

DECLARE ABC_Cursor CURSOR FOR
    SELECT APPLICATION_NR, REASON, REASON_TYPE
    FROM Table_12
    ORDER BY APPLICATION_NR, REASON, REASON_TYPE

    OPEN ABC_Cursor

    FETCH NEXT FROM ABC_Cursor   /* Prime the cursor */
    INTO @APPLICATION_NR, @REASON, @REASON_TYPE

    WHILE @@FETCH_STATUS = 0
    BEGIN

      SET @LATEST_DCSN_TM = (SELECT MAX(DCSN_TM)
                        FROM Table_12
                        WHERE APPLICATION_NR = @APPLICATION_NR AND
                              REASON = @REASON AND
                              REASON_TYPE = @REASON_TYPE)

      SET @DELETE_STRING = 'DELETE
                            FROM Table_12
                            WHERE DCSN_TM <> '''+@LATEST_DCSN_TM+'''
AND
                            APPLICATION_NR = '''+@APPLICATION_NR+'''
AND
                            REASON = '''+@REASON+''' AND
                            REASON_TYPE = '''+ @REASON_TYPE+ ''''

      EXEC(@DELETE_STRING)

      FETCH NEXT FROM ABC_Cursor
      INTO @APPLICATION_NR, @REASON, @REASON_TYPE
    END

  /* Clean house, always de-allocate the cursor */

  CLOSE ABC_Cursor
  DEALLOCATE ABC_Cursor
----------------------------------------------------------
Thanks,
Jim


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hugo Kornelis  
View profile  
 More options Sep 20 2006, 9:29 am
Newsgroups: microsoft.public.sqlserver.programming
From: Hugo Kornelis <h...@perFact.REMOVETHIS.info.INVALID>
Date: Wed, 20 Sep 2006 01:29:18 +0200
Local: Wed, Sep 20 2006 9:29 am
Subject: Re: Performance Issue
On 19 Sep 2006 09:56:50 -0700, Jim wrote:

>Hi,

>         I need to remove duplicate rows from a table.   The process
>that I am using, which is shown below, is extremely slow - it takes
>about 30 minutes to process 2000 rows.    Can anyone point out any
>obvious reasons that my technique is slow? - or perhaps propose a
>better technique?

Hi Jim,

Try it with this:

DELETE FROM Table_12
WHERE DCSN_TM <> (SELECT MAX(a.DCSN_TM)
                  FROM   Table_12 AS a
                  WHERE  a.APPLICATION_NR = Table_12.APPLICATION_NR
                  AND    a.REASON = Table_12.REASON
                  AND    a.REASON_TYPE = Table_12.REASON_TYPE);

(Untested - see www.aspfaq.com/5006 if you prefer a tested reply)

--
Hugo Kornelis, SQL Server MVP


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google