Skip to content

Instantly share code, notes, and snippets.

@MisterPhoton
Created January 3, 2011 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MisterPhoton/763987 to your computer and use it in GitHub Desktop.
Save MisterPhoton/763987 to your computer and use it in GitHub Desktop.
Notifier Query
SET @cutoff = date_add(now(), interval 421 MINUTE);
EXPLAIN SELECT
wpi.itemId,
wpi.label,
wpi.note,
wpi.dueDate,
wp.timeZone,
su.email,
su.firstName,
su.lastName
FROM
Wedding_Plan_Item AS wpi
JOIN Wedding_Plan AS wp USING(planId)
JOIN System_User AS su USING(userId)
WHERE
wpi.deleted = 0 AND
wpi.reminderSendDate is not null AND
wpi.reminderSentDate is null AND
wpi.reminderSendDate < @cutoff;
@MisterPhoton
Copy link
Author

EXPLAIN results:

ID  select_type  table  type    possible_keys  key           key_len  ref          rows   Extra
1   SIMPLE       wp     ALL     PRIMARY        null          null     null         18845  
1   SIMPLE       su     eq_ref  PRIMARY        PRIMARY       4        Plan.userId  1
1   SIMPLE       wpi    ref     planId_Index   planId_Index  5        Plan.planId  110    Using where

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment