Avoid ordering just by a timestamp

Try to also employ an id when possible.
Involves reworking some of the indices.
This commit is contained in:
Alexei Sorokin
2020-09-15 16:59:27 +03:00
parent 8079a476b6
commit 52d67b0f44
41 changed files with 633 additions and 656 deletions

View File

@@ -59,8 +59,8 @@ class Subscription extends Managed_DataObject
'subscription_uri_key' => array('uri'),
),
'indexes' => array(
'subscription_subscriber_created_idx' => array('subscriber', 'created'),
'subscription_subscribed_created_idx' => array('subscribed', 'created'),
'subscription_subscriber_created_subscribed_idx' => array('subscriber', 'created', 'subscribed'),
'subscription_subscribed_created_subscriber_idx' => array('subscribed', 'created', 'subscriber'),
'subscription_token_idx' => array('token'),
),
);
@@ -407,7 +407,7 @@ class Subscription extends Managed_DataObject
$sub->$by_type = $profile_id;
$sub->selectAdd($get_type);
$sub->whereAdd($get_type . ' <> ' . $profile_id);
$sub->orderBy('created DESC');
$sub->orderBy("created DESC, {$get_type} DESC");
$sub->limit($queryoffset, $querylimit);
if (!$sub->find()) {