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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:58:34+00:00 2026-06-05T10:58:34+00:00

I have this query (I didn’t write) that was working fine for a client

  • 0

I have this query (I didn’t write) that was working fine for a client until the table got more then a few thousand rows in it, now it’s taking 40 seconds+ on only 4200 rows.

Any suggetions on how to optimize and get the same result?

I’ve tried a few other methods but didn’t get the correct result that this slower query returned…

SELECT COUNT(*) AS num
  FROM `fl_events`
  WHERE id IN(
    SELECT DISTINCT (e2.id)
      FROM `fl_events` AS e1, fl_events AS e2
      WHERE e1.startdate >= now() AND e1.startdate = e2.startdate
  )
  ORDER BY `startdate`

Any help would be greatly appriciated!

  • 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-05T10:58:36+00:00Added an answer on June 5, 2026 at 10:58 am

    Appart from the obvious indexes needed, I don’t really get why you are joining your table with itself for choosing the IN condition. The ORDER BY is also not needed. Are you sure that your query can’t be written just like this?:

    SELECT COUNT(*) AS num
    FROM `fl_events` AS e1
    WHERE e1.startdate >= now() 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query working but it is not returning back exactly what I
I have this query which works correctly in MySQL. More background on it here
I have this query to fetch the total OrderStatus that have values 1 and
I have this query that works: select name, location_id from all_names where location_id in
i am trying this query but didn't work. ERROR: #1064 - You have an
I have this query that takes about 5 minutes to run in Oracle: select
how to write this query in sql : For every player that has played
I have this query that's running too slow. I'm not sure what all info
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
I'm in over my head with this query. I have a table which looks

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.