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 7549719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:01:05+00:00 2026-05-30T10:01:05+00:00

There are over 2 millions record in the table. I want to count how

  • 0

There are over 2 millions record in the table.

I want to count how many errors (with checked) in the table and how many has been checked.

I do two queries:

SELECT count(*) as CountError FROM table WHERE checked = 1 AND error != ''

–

SELECT count(*) as Checked FROM table WHERE checked = 1

The performance is really slow, it take about 5 mins to get the result. How to improve this?

I have already have index on status field for the UPDATE performance.

If I index on checked field – then UPDATE performance will be effected which I do not want that.

UPDATE happen more than SELECT.

The table are Innob

  • 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-05-30T10:01:06+00:00Added an answer on May 30, 2026 at 10:01 am

    You can try if making both counts in the same query is faster:

    select
      count(*) as CountError,
      sum(case when error != '' then 1 else 0 end) as Checked
    from table
    where checked = 1
    

    However, the difference will probably not be much to talk about. If you really want a difference then you need to add an index. Consider what the impact really would mean, and make an actual test to get a feel for what the impact could really be. If the update gets 10% slower and the select gets 100000% faster, then it might still be worth it.

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

Sidebar

Related Questions

I've been reading Entity Framework and people were crying over why there was not
There have been several questions over the past few days about the proper use
There exists an RSS feed with over 1000 items. I want to create a
I have a large table consisting of over 60 millions records and I would
I have a table that has grown to over 1 million records... today (all
I have a table that has 8 million records, with many fields, including lat/long
Has anyone been able to get a variable record length text file (CSV) into
Suppose I have a table with over a million entries and I want to
i have list of images and on mouse over there is option box shows
There seems to be some debate over refactoring to utilize java generics within my

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.