Optimize index sizes
This commit is contained in:
parent
2f5c6b2fc6
commit
439b1744f5
3 changed files with 69 additions and 9 deletions
|
@ -16,7 +16,7 @@ let config: IConfig = require('config')
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const LAST_MIGRATION_VERSION = 305
|
||||
const LAST_MIGRATION_VERSION = 310
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction,
|
||||
queryInterface: Sequelize.QueryInterface,
|
||||
sequelize: Sequelize.Sequelize,
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const indexNames = [
|
||||
'video_category',
|
||||
'video_licence',
|
||||
'video_nsfw',
|
||||
'video_language',
|
||||
'video_wait_transcoding',
|
||||
'video_state',
|
||||
'video_remote',
|
||||
'video_likes'
|
||||
]
|
||||
|
||||
for (const indexName of indexNames) {
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";')
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -102,16 +102,44 @@ const indexes: Sequelize.DefineIndexesOptions[] = [
|
|||
{ fields: [ 'createdAt' ] },
|
||||
{ fields: [ 'publishedAt' ] },
|
||||
{ fields: [ 'duration' ] },
|
||||
{ fields: [ 'category' ] },
|
||||
{ fields: [ 'licence' ] },
|
||||
{ fields: [ 'nsfw' ] },
|
||||
{ fields: [ 'language' ] },
|
||||
{ fields: [ 'waitTranscoding' ] },
|
||||
{ fields: [ 'state' ] },
|
||||
{ fields: [ 'remote' ] },
|
||||
{ fields: [ 'views' ] },
|
||||
{ fields: [ 'likes' ] },
|
||||
{ fields: [ 'channelId' ] },
|
||||
{
|
||||
fields: [ 'category' ], // We don't care videos with an unknown category
|
||||
where: {
|
||||
category: {
|
||||
[Sequelize.Op.ne]: null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: [ 'licence' ], // We don't care videos with an unknown licence
|
||||
where: {
|
||||
licence: {
|
||||
[Sequelize.Op.ne]: null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: [ 'language' ], // We don't care videos with an unknown language
|
||||
where: {
|
||||
language: {
|
||||
[Sequelize.Op.ne]: null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: [ 'nsfw' ], // Most of the videos are not NSFW
|
||||
where: {
|
||||
nsfw: true
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: [ 'remote' ], // Only index local videos
|
||||
where: {
|
||||
remote: false
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: [ 'uuid' ],
|
||||
unique: true
|
||||
|
|
Loading…
Reference in a new issue