mirror of
https://github.com/flarum/framework.git
synced 2025-03-15 00:05:12 +08:00
Add is_sticky, last_posted_at index to improve performance (#23)
This PR introduces an additional index [is_sticky, last_posted_at] to the discussions table. We discovered that when viewing discussions in a tag with a large number of discussions (approx 1.4M in our case), performance was poor when using the default sort criteria (sort by latest).
This commit is contained in:
parent
8e3e51a613
commit
82c57cd36a
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('discussions', function (Blueprint $table) {
|
||||
$table->index(['is_sticky', 'last_posted_at']);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('discussions', function (Blueprint $table) {
|
||||
$table->dropIndex(['is_sticky', 'last_posted_at']);
|
||||
});
|
||||
}
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user