Create a gist now

Instantly share code, notes, and snippets.

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
Owner

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