[DATABASE] Add explicit indices for all foreign keys
This adds a requirement for all definitions that have foreign keys to also require indices for all source (local) attributes mentioned in foreign keys. MariaDB/MySQL creates indices for source attributes automatically, so this serves as a way to get rid of those automatic indices and create clean explicit ones instead. In PostgreSQL, most of the time, indices on the source are necessary to decrease performance penalty of foreign keys (like in MariaDB), but they aren't created automatically, so this serves to remove that difference between PostgreSQL and MariaDB.
This commit is contained in:
@@ -60,6 +60,10 @@ class Activitypub_pending_follow_requests extends Managed_DataObject
|
||||
'activitypub_pending_follow_requests_local_profile_id_fkey' => ['profile', ['local_profile_id' => 'id']],
|
||||
'activitypub_pending_follow_requests_remote_profile_id_fkey' => ['profile', ['remote_profile_id' => 'id']],
|
||||
],
|
||||
'indexes' => [
|
||||
'activitypub_pending_follow_requests_local_profile_id_idx' => ['local_profile_id'],
|
||||
'activitypub_pending_follow_requests_remote_profile_id_idx' => ['remote_profile_id'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -95,6 +95,7 @@ class Happening extends Managed_DataObject
|
||||
'happening_uri_fkey' => array('notice', array('uri' => 'uri'))
|
||||
),
|
||||
'indexes' => array(
|
||||
'happening_profile_id_idx' => array('profile_id'),
|
||||
'happening_created_idx' => array('created'),
|
||||
'happening_start_time_end_time_idx' => array('start_time', 'end_time'),
|
||||
),
|
||||
|
@@ -85,7 +85,10 @@ class RSVP extends Managed_DataObject
|
||||
'rsvp_event_uri_fkey' => array('happening', array('event_uri' => 'uri')),
|
||||
'rsvp_profile_id_fkey' => array('profile', array('profile_id' => 'id'))
|
||||
),
|
||||
'indexes' => array('rsvp_created_idx' => array('created')),
|
||||
'indexes' => array(
|
||||
'rsvp_event_uri_idx' => array('event_uri'),
|
||||
'rsvp_created_idx' => array('created'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -55,6 +55,7 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject
|
||||
'gnusocialprofileextensionresponse_extension_id_fkey' => ['gnusocialprofileextensionfield', ['extension_id' => 'id']],
|
||||
],
|
||||
'indexes' => [
|
||||
'gnusocialprofileextensionresponse_profile_id_idx' => ['profile_id'],
|
||||
'gnusocialprofileextensionresponse_extension_id_idx' => ['extension_id'],
|
||||
],
|
||||
];
|
||||
|
@@ -1,48 +1,42 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Who received a group message
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Data class for group direct messages for users
|
||||
*
|
||||
* @category GroupPrivateMessage
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category GroupPrivateMessage
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class Group_message_profile extends Managed_DataObject
|
||||
{
|
||||
@@ -66,10 +60,13 @@ class Group_message_profile extends Managed_DataObject
|
||||
'group_message_profile_to_profile_fkey' => array('profile', array('to_profile' => 'id')),
|
||||
'group_message_profile_group_message_id_fkey' => array('group_message', array('group_message_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'group_message_profile_group_message_id_idx' => array('group_message_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function send($gm, $profile)
|
||||
public function send($gm, $profile)
|
||||
{
|
||||
$gmp = new Group_message_profile();
|
||||
|
||||
@@ -87,13 +84,13 @@ class Group_message_profile extends Managed_DataObject
|
||||
return $gmp;
|
||||
}
|
||||
|
||||
function notify()
|
||||
public function notify()
|
||||
{
|
||||
// XXX: add more here
|
||||
$this->notifyByMail();
|
||||
}
|
||||
|
||||
function notifyByMail()
|
||||
public function notifyByMail()
|
||||
{
|
||||
$to = User::getKV('id', $this->to_profile);
|
||||
|
||||
@@ -117,21 +114,23 @@ class Group_message_profile extends Managed_DataObject
|
||||
// TRANS: %1$s is the sending user's long name, %2$s is the sending user's nickname,
|
||||
// TRANS: %3$s is the message content, %4$s a URL to the message,
|
||||
// TRANS: %5$s is the StatusNet sitename.
|
||||
$body = sprintf(_m("%1\$s (%2\$s) sent a private message to group %3\$s:\n\n".
|
||||
"------------------------------------------------------\n".
|
||||
"%4\$s\n".
|
||||
"------------------------------------------------------\n\n".
|
||||
"You can reply to their message here:\n\n".
|
||||
"%5\$s\n\n".
|
||||
"Do not reply to this email; it will not get to them.\n\n".
|
||||
"With kind regards,\n".
|
||||
"%6\$s"),
|
||||
$from_profile->getBestName(),
|
||||
$from_profile->nickname,
|
||||
$group->nickname,
|
||||
$gm->content,
|
||||
common_local_url('newmessage', array('to' => $from_profile->id)),
|
||||
common_config('site', 'name')) . "\n";
|
||||
$body = sprintf(
|
||||
_m("%1\$s (%2\$s) sent a private message to group %3\$s:\n\n"
|
||||
. "------------------------------------------------------\n"
|
||||
. "%4\$s\n"
|
||||
. "------------------------------------------------------\n\n"
|
||||
. "You can reply to their message here:\n\n"
|
||||
. "%5\$s\n\n"
|
||||
. "Do not reply to this email; it will not get to them.\n\n"
|
||||
. "With kind regards,\n"
|
||||
. "%6\$s"),
|
||||
$from_profile->getBestName(),
|
||||
$from_profile->nickname,
|
||||
$group->nickname,
|
||||
$gm->content,
|
||||
common_local_url('newmessage', ['to' => $from_profile->id]),
|
||||
common_config('site', 'name')
|
||||
) . "\n";
|
||||
|
||||
$headers = _mail_prepare_headers('message', $to->nickname, $from_profile->nickname);
|
||||
|
||||
|
@@ -37,6 +37,9 @@ class Mention_url_profile extends Managed_DataObject
|
||||
'foreign keys' => array(
|
||||
'mention_url_profile_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'mention_url_profile_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -90,6 +90,7 @@ class ModLog extends Managed_DataObject
|
||||
],
|
||||
'indexes' => [
|
||||
'modlog_profile_id_created_idx' => ['profile_id', 'created'],
|
||||
'modlog_moderator_id_idx' => ['moderator_id'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user