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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:04:45+00:00 2026-05-27T22:04:45+00:00

Querycache is disabled! Indexes are 100 % loaded in RAM index is only ID

  • 0
  • Querycache is disabled!
  • Indexes are 100 % loaded in RAM
  • index is only ID

1benchmark:

"SELECT title FROM posts LIMIT ?, 15";
? = rand(1,183655);

EXPLAIN 
id  select_type     table   type    possible_keys   key     key_len     ref     rows    Extra
1   SIMPLE  posts   ALL     NULL    NULL    NULL    NULL    183637  

after doing 100 loops it took over 100 sec.

2Benchmark:

"SELECT title FROM posts WHERE id = 78845 OR id = 158738 OR id = 57065 OR id = 146797 OR id = 78918 OR id = 65227 OR id = 117987 OR id = 92541 OR id = 39782 OR id = 1958 OR id = 180384 OR id = 170758 OR id = 102227 OR id = 180223 OR id = 46391";

    in each loop every id is generated via rand(1,183655);

after doing 100 loops it took 6 sec to finish and it uses the primary key.

The problem is I think in the LIMIT MySQL doesn’t use the primary key for the id.

After testing with Limit again:

SECONDS:        LOOPS:  SQL:
41.560034990311 =    30 =   "SELECT title FROM posts LIMIT ?, 15";
36.302664995193 =    30 =   "SELECT title FROM posts ORDER BY id LIMIT ?, 15";
70.335160970688 =    30 =   "SELECT title FROM posts ORDER BY id ASC LIMIT ?, 15";
48.453547000885 =    30 =   "SELECT id, title FROM posts LIMIT ?, 15"

Somehow but I’m not 100 % sure. I updated on my VMware PHP5.1.6 to PHP5.3 since then I noticed, that these LIMIT queries take longer.

  • 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-27T22:04:45+00:00Added an answer on May 27, 2026 at 10:04 pm

    You could run this instead:

    SELECT title 
    FROM posts 
    WHERE id >= ?
    LIMIT 15
    

    It’s not equivalent to the LIMIT ?, 15 but it will use the index.

    You can also check this related article.

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

Sidebar

Related Questions

Query A Select id from jobs; | 55966 | | 55971 | +-------+ 10705
I am doing a very simple select from a table like SELECT column FROM
From my sql log file, I think the QueryCache's physical properties are configured by
I need to try & clear only a single query (actually a stored proc)
Rails' ActiveRecord has a feature called Query Caching (ActiveRecord::QueryCache) which saves the result of
The Query Performance chapter from High Performance MySQL book (2004) said MySQL(4.0.1) attempts to
The title obviously states it : I can't make the second-level cache work for
I get a mysql error: #update (ActiveRecord::StatementInvalid) Mysql::Error: #HY000Got error 139 from storage engine:
I want to have this cached query in NHibernate: Configuration configurationEntry = session.CreateQuery(from Configuration
i need to detect from php if mysql query cache plugin is installed, any

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.