Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:57:31+00:00 2026-06-10T18:57:31+00:00

I am running a query on SQLSERVER 2008. The query is taking 4 seconds

  • 0

I am running a query on SQLSERVER 2008. The query is taking 4 seconds to process. I cannot understand why it’s taking so long.

SELECT tbl_Operations.Workcenter
,SUM(tbl_Used_Components.Used_Quantity) as CNF_TODAY
FROM tbl_Used_Components
JOIN tbl_Pack_Division on tbl_Pack_Division.Pack_Division_ID =        
tbl_Used_Components.Pack_Division_ID
JOIN tbl_Operations on tbl_Operations.Operation_ID = tbl_Pack_Division.Operation_ID

where CONVERT(date, tbl_Pack_Division.Stop_Time) = CONVERT(date, getdate())
AND tbl_Pack_Division.Memo = 'NORMAL'
and tbl_Pack_Division.Status = 'CNF_MACH'
GROUP BY tbl_Operations.Workcenter

The problem is in the where clause. When i run the query without Where clause it runs in 0.1 second. When I add the first 2 arguments it still runs fine. But when I add the third argument on Status-field it goes wrong.

How can this be a problem? It is a selection on the same granularity as the seond one (Memo-field).

EDIT:

Status varchar(10) — Can have 5 different values

Memo varchar(150)

Only index: Pack_Division_ID bigint

XML Execution plan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:57:33+00:00Added an answer on June 10, 2026 at 6:57 pm

    Generally if you add one more column to the where it means that it has to be read fist from the table. So without a where condition may your query could be faster even if it has more rows to aggregate because it can use indexes only, and has to read less.

    If you check the EXECUTION PLAN it says you should use an index on that two column, which would give you a boost.

    The problematic step is here:

    <RelOp AvgRowSize="48" EstimateCPU="0.136774" EstimateIO="1.94831" 
    EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" 
    LogicalOp="Clustered Index Scan" NodeId="6" Parallel="false" 
    PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="2.08508" 
    TableCardinality="124197">
    
     <ScalarOperator ScalarString="[MII03].[dbo].[tbl_Pack_Division].[Memo]='NORMAL'
     AND [MII03].[dbo].[tbl_Pack_Division].[Status]='CNF_MACH' 
    AND CONVERT(date,[MII03].[dbo].[tbl_Pack_Division].
    [Stop_Time],0)=CONVERT(date,getdate(),0)">
    

    I think that the answer could be the low “selectivity” in your column Status, so since it tries to use all of the three values in the same time it means now more test, because the status, fitting more times then simply the first two values. However I’m not 100% sure how the optimizer working with the AND logical operators (what does mean the order)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running this query takes a long time: SELECT host,ip FROM arecords WHERE ip IN
i am wondering is that possible (best practice) to run two long running query
After running this query statement with my database: select * from articles where content
I'm running a query which looks like this SELECT parent.field, child.field FROM parent JOIN
I've got 2 servers running SQL Server 2008, and I have the following query:
I've got a really long running SQL query (data import, etc). It's crap -
I'm running the simple query on SQL Server 2008 R2 for the following table:
I'm running SQL Server 2008. I've built a large search query (contained in a
Running this query in sql server 2008 now, but soon plan to move it
When running a very simple query in SQL Server 2000. SELECT getDate() Most queries

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.