Improve performance of a subscriber listing on MySQL 5.5 and lower [MAILPOET-867]

This commit is contained in:
Alexey Stoletniy
2017-03-30 13:12:53 +03:00
parent 5f75efddf1
commit 6811d8e38d

View File

@ -787,20 +787,13 @@ class Subscriber extends Model {
static function withoutSegments($orm) {
return $orm->select(MP_SUBSCRIBERS_TABLE.'.*')
->rawJoin(
'LEFT OUTER JOIN (
SELECT `subscriber_id`
FROM '.MP_SUBSCRIBER_SEGMENT_TABLE.'
WHERE `status` = "'.self::STATUS_SUBSCRIBED.'"
)',
array(
MP_SUBSCRIBERS_TABLE.'.id',
'=',
MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id'
),
MP_SUBSCRIBER_SEGMENT_TABLE
)
->whereNull(MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id');
->whereRaw(
MP_SUBSCRIBERS_TABLE . '.id NOT IN (
SELECT `subscriber_id`
FROM '.MP_SUBSCRIBER_SEGMENT_TABLE.'
WHERE `status` = "'.self::STATUS_SUBSCRIBED.'"
)'
);
}
static function createMultiple($columns, $values) {