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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:36:04+00:00 2026-06-16T14:36:04+00:00

I have big table with 22 millions records. I want to execute next query:

  • 0

I have big table with 22 millions records.
I want to execute next query:

select auto_alerts from alerts_stat  where endDate > "2012-12-01"

To improve performance I added BTREE index for endData field:

CREATE INDEX endDate_index USING BTREE ON alerts_stat(endDate)

After I start to analyze query execution plan:

When I want to get parameters from 15 to 7 days before now:

explain select alerts_sp from alerts_stat 
where endDate between CURDATE() - 15 and CURDATE() - 7;

I got next execution plan to process 2,762,088 rows.

'1', 'SIMPLE', 'browser_plugin_alerts_stat', 'range', 'endDate_index', 'endDate_index', '4', NULL, '2762088', 'Using where'

When I increase interval by one day, i received:

explain select alerts_sp from alerts_stat 
where endDate between CURDATE() - 15 and CURDATE() - 6;

EXPLAIN said MySQL plan to process all 22,923,126 rows.

'1', 'SIMPLE', 'browser_plugin_alerts_stat', 'ALL', 'endDate_index', NULL, NULL, NULL, '22932390', 'Using where'

For example select without any conditions in WHERE process 22,925,642.

May I improve execution plan? Maybe I have mistake somewhere, or is normal MySQL behaivior?

  • 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-16T14:36:07+00:00Added an answer on June 16, 2026 at 2:36 pm

    When result set exceeds 8-9% of all rows, MySQL does full table scan.
    To me, it looks like that one day you add swings MySQL in full table scan direction.
    You could try forcing index to see if result is better.

    UPDATE:

    From what I’ve read, MySQL query optimizer tends to choose wrong in borderline cases like this, so it could easily work better forcing an index. Otherwise, this is simple query, and I don’t much more room for optimization.

    Maybe creating a Covering index on these two columns and forcing its use could give best results.

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

Sidebar

Related Questions

I have big records to copy values from table B to table A. Currently
I have a big problem. I want to extract text from html table that
I have a big MySQL table (around 50 GB, tens of millions of records),
I have this big table called StateChanges (1.9 million rows) from a third party
I have a big Table , about 1 million records , and it's increasing
Has anyone generated a big, really big table about a millions records using this
I have the following query running against a mysql database: select value from fact_data
i have big table with many html items such as select, textbox, radio-button, checkbox.
I have a big table and want to sort using tablesorter. The problem I'm
I have the following problem: my table is big enought (millions of data rows),

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.