CPU Usage

Posted on 2014-08-12
Last Modified: 2014-08-22
I have a website that has SQL Server Db as back end. I found that the CPU usage was more than normal. I found a SQL code to show most CPU consuming query I fixed some of them and it return noticeable amount of CPU Usage.

The only SQL code that I dont know how to get it optimized to not use too much CPU redources is this one:

SELECT top 5 [ID], [Title], [Details],[IPhoto] FROM [qryWords] WHERE lang=1 and id<> 59476  and [Title] like N'%no%' order by id desc

Note: qryWord is a view and the SQL code is as following:

SELECT        word, ID, Title, Details, Visible, Lang, IPhoto
FROM            dbo.tblBabeteLekchwekan
WHERE        (Visible = 1) AND (Lang = 1)

Do you have any Idea how can I tune this query to use as low as CPU resources?
Question by:Yadtrt
    LVL 75

    Accepted Solution

    '%no%' filter condition seems to be the reason.  I know its always possible to avoid those sorts of searches, is highly recommended. Your option to speed up this operation will be the full text indexing.
    also you don't really need lang=1 in your where condition because its already on the view .
    LVL 35

    Expert Comment

    by:David Todd

    >>  id<> 59476  
    This search argument is non-sargable.

    LVL 47

    Expert Comment

    <> is sargable, but not likely to improve performance

    so the most likely performance culprit is: [Title] like N'%no%'
    which is probably causing a table scan

    by the way. top 5 isn't helping either because it adds the need to order, and with '%no%' probably matching many more than 5 results all records are scanned to evaluate the filter then all matches sorted by id then just 5 of those returned.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now