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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:20:44+00:00 2026-05-25T21:20:44+00:00

I use the following query to find users that I need to send daily

  • 0

I use the following query to find users that I need to send daily reminders based on their settings and timezone. It works but turned up that it uses about 50% CPU and its really heavy even when I add Limit 0,100.

(It even causes phpMyAdmin to crash or something)

Users table: 3000 records,
Posts table: 12000+ records,
Settings table: 3000 records,
Reminders table: 80000 records (Keeps user_id and date to prevent duplicates)

   SELECT u.`id`, u.`fullname`, u.`email`, u.`hash`, s.`timezone`
   FROM `users` u
   LEFT JOIN `reminders` rm ON rm.`user_id` = u.`id` AND rm.`date` = CURDATE()
   LEFT JOIN `settings` s ON s.`user_id` = u.`id`
   LEFT JOIN `posts` p ON p.`user_id` = u.`id` AND p.`date` = DATE(CONVERT_TZ(UTC_TIMESTAMP, 'UTC', s.`timezone`))
   WHERE HOUR(CONVERT_TZ(UTC_TIMESTAMP, 'UTC', s.`timezone`)) = s.`notify_hour`
   AND s.`notify` = 1 AND u.`active` = 1 AND rm.`id` IS NULL AND p.`id` IS NULL
   GROUP BY u.`id` LIMIT 0,100

I run this query every 10 minutes and I’m sending reminders through sendgrid.com SMTP server.
Can you please help me optimize this query so that it doesn’t use this much resource?

Thank you (and sorry for my English)

  • 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-25T21:20:45+00:00Added an answer on May 25, 2026 at 9:20 pm

    Do you have the fields properly indexed?
    here is a suggestion:

    Try to index the user_id field on all the tables it should make it faster.

    Also the conversion of dates is eating up the cpu time, you should store the dates in UTC format in your database this way you will avoid a huge overhead

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

Sidebar

Related Questions

for example i use following command to find a record SELECT `users`.`mail` FROM `users`
I have the following LINQ query that I need to translate to Entity SQL
I have the following query that I need to convert to rails like syntax.
I use the following XPATH Query to list the object under a site. ListObject[@Title='SomeValue']
I use the following mysql query, DELIMITER $$ DROP PROCEDURE IF EXISTS `allied`.`aboutus_delete`$$ CREATE
I'm using Firebird 2.1. I could use some help creating the following query or
I face the following exception when i try to use parametrized query with informix
I want users to be able to use the facebook send button to send
I use the following query to get a result set var overlaps = from
I've come to find out that the following SQL is not possible due to

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.