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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:07:21+00:00 2026-06-11T00:07:21+00:00

I would like to know what are the best solutions to optimize the response

  • 0

I would like to know what are the best solutions to optimize the response time of an SQL query for a table containing more than 2.000.000 records

As a solution, I thought of a virtual table by creating a SQL view (In fact, I prefer mysql to search early in the lines created this year because the data of this application is based on the season.)

Is there a better solution or recommendation?

eg to search all rent lines of rent 12

before =>
select * from rent_lines Where rent_id = 12

Now =>
  I created a view

CREATE VIEW v_rent_lines
AS SELECT rent_id, category_id, customer_id, amount ..
Where rent_lines FROM created_at > = (select starts_on from seasons where current = true)

select * from v_rent_lines Where rent_id = 12

Notes:

  • database engine is being used InnoDB

  • I added indexes table (index_rent_lines_on_rent_id, index_rent_lines_on_category_id, index_rent_lines_on_customer_id)

  • rent has many rent_lines

  • 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-11T00:07:22+00:00Added an answer on June 11, 2026 at 12:07 am

    The view is not really helping anything in this case. Views primarily help you, as a developer, by letting you refer to a more complex query by name rather than having to repeat the details all the time. They don’t really help mysql all that much.

    You have a lot of options.

    1. If you don’t yet, ensure that you have an index where rent_id is either the only field in the index, or the first field in the index. For example:

      create index rent_id_idx on rent_lines (rent_id)
      
    2. You can consider using mysql’s partitioning system and partitioning on rent_id

    3. You can create an index that will have a lower cardinality by doing something like:

      alter table rent_lines add rent_id_bucket smallint unsigned not null after rent_id;
      update rent_lines set rent_id_bucket = rent_id>>16;
      alter table rent_lines add key rent_id_bucket_idx(rent_id_bucket);
      

      This will let you do a query like:

      select * from rent_lines where rent_id_bucket = 16>>16 and rent_id=16
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know what is the best solution for storing large amount
I would like to know what are the best approaches for protecting apllication and
I would like to know what's the best way to organize my php project
I would like to know what is the best import strategy within django reusable
I would like to know what is the best, fastest and easiest way to
I would like to know What is the best way to include 3rd party
I would like to know how to use Queue in the best functional way.
I would like to know the best way of parsing an input where multiple
I would like to know the ways I could add more security to the
I am rather new to Sitecore and would like to know a bit more

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.