public
Last active

Notifier Query

  • Download Gist
NotifierQuery.sql
SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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;

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.