From 53af27a30343899660c2cf35fe0f8870278abd5f Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Sun, 3 Nov 2019 18:57:03 +0300 Subject: [PATCH] [NodeInfo][DATABASE] Adjust indices of the "notice" and "user" tables On big databases these queries from the Nodeinfo plugin choked up: SELECT profile_id FROM notice WHERE notice.created >= (CURRENT_DATE - INTERVAL '180' DAY) AND notice.is_local = 1; SELECT id FROM "user" WHERE "user".created >= (CURRENT_DATE - INTERVAL '180' DAY); --- classes/Notice.php | 1 + classes/User.php | 1 + 2 files changed, 2 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index 4b6f7ee19a..31243887c7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -107,6 +107,7 @@ class Notice extends Managed_DataObject 'indexes' => array( 'notice_created_id_is_local_idx' => array('created', 'id', 'is_local'), 'notice_profile_id_idx' => array('profile_id', 'created', 'id'), + 'notice_is_local_created_profile_id_idx' => array('is_local', 'created', 'profile_id'), 'notice_repeat_of_created_id_idx' => array('repeat_of', 'created', 'id'), 'notice_conversation_created_id_idx' => array('conversation', 'created', 'id'), 'notice_object_type_idx' => array('object_type'), diff --git a/classes/User.php b/classes/User.php index 46d28443a1..3f2b96105f 100644 --- a/classes/User.php +++ b/classes/User.php @@ -102,6 +102,7 @@ class User extends Managed_DataObject 'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')), ), 'indexes' => array( + 'user_created_idx' => array('created'), 'user_smsemail_idx' => array('smsemail'), ), );