[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:
Alexei Sorokin
2020-07-31 16:36:40 +03:00
committed by Diogo Peralta Cordeiro
parent 665e4574da
commit bee3dea9c2
22 changed files with 142 additions and 58 deletions

View File

@@ -90,6 +90,7 @@ class ModLog extends Managed_DataObject
],
'indexes' => [
'modlog_profile_id_created_idx' => ['profile_id', 'created'],
'modlog_moderator_id_idx' => ['moderator_id'],
],
];
}