Paste P6430

Dispatch getCandidateClients possible alternative
ActivePublic

Authored by Addshore on Dec 5 2017, 4:09 PM.
(
/*This is essentially the query that is being run currently*/
SELECT
chd_site,
(SELECT max( change_id ) as maxid FROM wb_changes) as max,
chd_seen,
chd_touched,
change_time,
((SELECT max( change_id ) as maxid FROM wb_changes) - chd_seen) as lagChanges,
(DATE_FORMAT(NOW(),'%Y%m%d%H%i%s') - change_time) as lagTime,
'current' as query
FROM wb_changes_dispatch
LEFT JOIN wb_changes ON chd_seen = change_id
WHERE
(
chd_touched < DATE_FORMAT(NOW(),'%Y%m%d%H%i%s') - 25/*CHANGEMEdispatchInterval*/
OR ( (SELECT max( change_id ) as maxid FROM wb_changes) - chd_seen ) > 420/*CHANGEMEbatchSize*/
)
AND ( chd_seen < (SELECT max( change_id ) as maxid FROM wb_changes) )
AND ( chd_disabled = 0 )
ORDER BY chd_seen ASC
LIMIT 5/*CHANGEMErandomness*/
)
UNION ALL
(
/*This is a query with the ORDERBY modified*/
SELECT
chd_site,
(SELECT max( change_id ) as maxid FROM wb_changes) as max,
chd_seen,
chd_touched,
change_time,
((SELECT max( change_id ) as maxid FROM wb_changes) - chd_seen) as lagChanges,
(DATE_FORMAT(NOW(),'%Y%m%d%H%i%s') - change_time) as lagTime,
'new' as query
FROM wb_changes_dispatch
LEFT JOIN wb_changes ON chd_seen = change_id
WHERE
(
chd_touched < DATE_FORMAT(NOW(),'%Y%m%d%H%i%s') - 25/*CHANGEMEdispatchInterval*/
OR ( (SELECT max( change_id ) as maxid FROM wb_changes) - chd_seen ) > 420/*CHANGEMEbatchSize*/
)
AND ( chd_seen < (SELECT max( change_id ) as maxid FROM wb_changes) )
AND ( chd_disabled = 0 )
ORDER BY lagTime DESC/*order by the lag time...*/
LIMIT 5/*CHANGEMErandomness*/
);
Addshore created this paste.Dec 5 2017, 4:09 PM