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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:39:23+00:00 2026-06-11T08:39:23+00:00

I have a mysql database with a table with about 40k entries. Executing the

  • 0

I have a mysql database with a table with about 40k entries. Executing the following statement takes about 10 seconds (Database is already selected):

SELECT * FROM MyTable WHERE Column < 3

Why does this take so long and how do I improve the performance?
Are other Databases faster? (e.g. MongoDB, CouchDB, … ) I’d prefer to use a MySQL Database though.

EDIT:

The following query…

EXPLAIN SELECT * FROM MyTable WHERE Column < 3;

results in the following:

id  select_type table   type    possible_keys   key key_len ref rows    Extra
1   SIMPLE  Occurances  index   NULL    SearchString    102 NULL    40242   Using where; Using index

The following query shows the distribution of values in the Column

SELECT COUNT(*), Column FROM MyTable GROUP BY Column;

The result is the following:

COUNT(*)    Column
43      0
5       1
106     2
71      3
42      4
283     5
2337    6
9491    7
22073   8
1191    9
1064    10
1105    11
919     12
393     13
288     14
288     15
200     16
123     17
71      18
71      19
36      20
10      21
13      22
8       23
4       24
3       25
4       29
  • 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-11T08:39:25+00:00Added an answer on June 11, 2026 at 8:39 am

    I’d venture to guess that you have no index on the Column column. Try creating one:

    CREATE INDEX idx_MyTable_Column ON MyTable (Column);
    

    Try comparing the output of EXPLAIN before and after you create the index:

    EXPLAIN SELECT * FROM MyTable WHERE Column < 3;
    

    You should see that with the index, an index scan (or better) is performed.

    An index will only help you if a small enough set of rows match your criteria. If most of the table matches the expression Column < 3 then an index won’t help and the planner will fall back on a table scan, since that will turn out to be faster than using the index.


    If you want a more detailed answer, then you’ll have to provide more information. The output of these two queries would be helpful:

    EXPLAIN SELECT * FROM MyTable WHERE Column < 3;
    SELECT COUNT(*), Column FROM MyTable GROUP BY Column;
    

    As well as a list of indexes on MyTable.

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

Sidebar

Related Questions

Greetings friends, In my MySQL database, I have 'MAB' table which contains information about
I have the following database table with information about people, diseases, and drugs: PERSON_T
I have a MySQL database-table with the following colums ID status (can contain values
I have a mysql database with a table in the following format: ID: 1
I have a MySQL database table containing information about places. I'm trying to fetch
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I have a MySQL database table called Participant that looks something like this: (idParticipant)
i have a large mysql database table in which one column contains values ranging
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database where the table was set up to store the

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.