perf: Add missing indexes (#10124)

This commit is contained in:
Tom Moor
2025-09-08 02:15:49 +02:00
committed by GitHub
parent 97fc848044
commit a44a612387
2 changed files with 27 additions and 2 deletions
@@ -0,0 +1,18 @@
"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
await queryInterface.addIndex("revisions", ["createdAt"], {
concurrently: true,
});
await queryInterface.addIndex("user_permissions", ["sourceId"], {
concurrently: true,
});
},
async down(queryInterface) {
await queryInterface.removeIndex("user_permissions", ["sourceId"]);
await queryInterface.removeIndex("revisions", ["createdAt"]);
},
};
@@ -19,10 +19,15 @@ export default class BacklinksProcessor extends BaseProcessor {
if (!document) {
return;
}
// Note: These can be UUID or slugs
const linkIds = DocumentHelper.parseDocumentIds(document);
await Promise.all(
linkIds.map(async (linkId) => {
const linkedDocument = await Document.findByPk(linkId);
const linkedDocument = await Document.findByPk(linkId, {
attributes: ["id"],
});
if (!linkedDocument || linkedDocument.id === event.documentId) {
return;
@@ -61,7 +66,9 @@ export default class BacklinksProcessor extends BaseProcessor {
// create or find existing backlink records for referenced docs
await Promise.all(
linkIds.map(async (linkId) => {
const linkedDocument = await Document.findByPk(linkId);
const linkedDocument = await Document.findByPk(linkId, {
attributes: ["id"],
});
if (!linkedDocument || linkedDocument.id === event.documentId) {
return;