Optimise tasks SQL query in inactive subscribers detection
[MAILPOET-3582]
This commit is contained in:
committed by
Veljko V
parent
abca6729e8
commit
694dde085f
@ -94,15 +94,14 @@ class InactiveSubscribersController {
|
|||||||
(INDEX task_id_ids (id))
|
(INDEX task_id_ids (id))
|
||||||
SELECT DISTINCT task_id as id FROM $sendingQueuesTable as sq
|
SELECT DISTINCT task_id as id FROM $sendingQueuesTable as sq
|
||||||
JOIN $scheduledTasksTable as st ON sq.task_id = st.id
|
JOIN $scheduledTasksTable as st ON sq.task_id = st.id
|
||||||
WHERE st.processed_at > '%s'
|
JOIN (
|
||||||
AND st.processed_at < '%s'
|
SELECT so.newsletter_id
|
||||||
AND EXISTS (
|
|
||||||
SELECT 1
|
|
||||||
FROM $statisticsOpensTable as so
|
FROM $statisticsOpensTable as so
|
||||||
WHERE so.created_at > '%s'
|
GROUP BY so.newsletter_id
|
||||||
AND so.newsletter_id = sq.newsletter_id
|
) sno ON sno.newsletter_id = sq.newsletter_id
|
||||||
)",
|
WHERE st.processed_at > '%s'
|
||||||
$thresholdDateIso, $dayAgoIso, $thresholdDateIso
|
AND st.processed_at < '%s'",
|
||||||
|
$thresholdDateIso, $dayAgoIso
|
||||||
);
|
);
|
||||||
ORM::rawExecute($inactivesTaskIdsTable);
|
ORM::rawExecute($inactivesTaskIdsTable);
|
||||||
$this->inactivesTaskIdsTableCreated = true;
|
$this->inactivesTaskIdsTableCreated = true;
|
||||||
|
Reference in New Issue
Block a user