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

  • Home
  • SEARCH
  • 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 8468595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:58:44+00:00 2026-06-10T15:58:44+00:00

I am using a mysql database. The query is executed directly via the workbench

  • 0

I am using a mysql database. The query is executed directly via the workbench tool.
The query looks like following:

SELECT records.received, data.value 
FROM product 
       JOIN records 
            on product.productId= records.productId 
       JOIN data 
            ON records.recordId = data.recordId 
       JOIN dataTypes 
            ON data.typeId = dataTypes.typeId 
ORDER BY records.received DESC

The data table has 1million entries.
The execution of this statement lasts 7 seconds. The reason seems to be the ORDER BY clause.

Can someone give me a hint how to speed it up.

Edit: sorry I forgot to add the structure:

products: PK is productId (it has only 5 entries)

records: PK is recordId and FK is productId

data: PK is dataId and FK recordId and typeId

dataTypes: PK is typeId

There is an Index on records.received and on all PK and FK.

Here is the output of EXPLAIN:

id,select_type,table,type,possible_keys,key,key_len,ref,rows,Extra
1,SIMPLE,products,const,PRIMARY,PRIMARY,4,const,1,"Using index
1,SIMPLE,dataTypes,const,PRIMARY,PRIMARY,4,const,1,"Using index"
1,SIMPLE,records,ref,"PRIMARY,productId",productId,4,const,127142,"Using where"
1,SIMPLE,data,ref,"recordId,typeId",recordId,4,top70.records.recordId,1,"Using where"
  • 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-10T15:58:45+00:00Added an answer on June 10, 2026 at 3:58 pm
    ALTER TABLE `records` ADD INDEX `index1` (`received`);
    ALTER TABLE `data` ADD INDEX `index2` (`value `);
    

    try to index your coloumns on which you are using where clause or selecting the coloumns

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

Sidebar

Related Questions

I am using JDBC to query a MySQL database for specific records from two
I'm trying to query a MySQL database using an array but I'm having trouble!
I'm using CodeIgniter's Active Record class to query the MySQL database. I need to
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
My problem is when using C# and MySQL database to save some records by
I have the following prepared query I am using with mysql and php. It
In my application I'm using ADODB to query a MySQL database. This goes very
I am using MySQL database. When I execute a query which the main table(20
I'm using the following code to (attempt to) query a database: Query query =
I'm using Mysql database and neatbeans IDE conncting by mysql-connector-java-5.1.21 jdbc , and I

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.