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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:40:24+00:00 2026-06-05T04:40:24+00:00

I am trying to get all the entries in a session log table where

  • 0

I am trying to get all the entries in a session log table where a session has more than 10 entries (i.e. the count of the session_id is greater than 10). What I have right now are two select statements:

select * from log_metrics where session_id in 
( select session_id from log_metrics 
  group by session_id having count(*) > 10
)

The log_metrics table is quite large, aprox. 7,700,000 rows. The inner select takes 12.88 seconds and finds 178,000 session id’s. The whole query doesn’t finish running written like this, but when adding limit 10 to the end of the outer select it completes in 18 seconds, limit 100 completes in 3 min 35 sec. I tried adding the limit to the inner select but got the following error:

ERROR 1235 (42000): This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME subquery’

Is there a way to rewrite this query to speed things up? I only need to get about 5,000 rows from log_metrics returned, not the total 178,000 of the session id’s.

Thanks for any help you might be able to give. I am new to mysql and posting so pardon any etiquette mis-steps.

  • 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-05T04:40:26+00:00Added an answer on June 5, 2026 at 4:40 am

    I have no idea if this will work (I don’t know what version of mySQL you have, and I don’t have an instance regardless), but would using a JOIN work as you want?

    SELECT *
    FROM log_metrics a
    JOIN (SELECT session_id
          FROM log_metrics
          GROUP BY session_id
          HAVING COUNT(session_id) > 10
          LIMIT 5000) b
    ON b.session_id = a.session_id
    

    You didn’t mention this, but for future questioners, the reason he needs the LIMIT statement inside the inner query is because he wants (a maximum of) 5000 session_ids, not total rows from the log (which could be 50,000 rows or more returned).

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

Sidebar

Related Questions

I'm working with the Wufoo api ( https://{subdomain}.wufoo.com/api/v3/forms/{formIdentifier}/entries.{xml|json} ) trying to get all of
I'm trying to get all duplicate rows from a DB. Lets say I have
I am trying to get all option values that have no attribute value. So
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
trying to get all the dates from the db that are within the current
I trying to get all the SATA hardware devices that connected. How can i
iam trying to get all object's xpath's from loaded page via selenium something similar
Im trying to get all Leads / Contact / Accounts from the database. So
I've been trying to get all the pixels of a line which is being

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.