[GH-ISSUE #49] 性能优化建议 #32

Closed
opened 2026-02-26 12:17:38 +03:00 by kerem · 1 comment
Owner

Originally created by @Selenium39 on GitHub (May 20, 2025).
Original GitHub issue: https://github.com/beilunyang/moemail/issues/49

当前worker/cleanup.ts定时清理邮箱和邮件会导致大量的读取行,很容易超过cloudflare的5m限制。

Image

Image

建议一:当前message已经设置了级联删除,删除邮箱会自动删除邮件,无需再手动删除邮件

 emailId: text("emailId")
    .notNull()
    .references(() => emails.id, { onDelete: "cascade" }),

建议二:由于不用手动删除邮件,所以不用先查询出email id再删除了,直接根据expires_at删除邮箱

建议三:email表给expires_at增加索引,message表给emailId增加索引

Originally created by @Selenium39 on GitHub (May 20, 2025). Original GitHub issue: https://github.com/beilunyang/moemail/issues/49 当前`worker/cleanup.ts`定时清理邮箱和邮件会导致大量的读取行,很容易超过cloudflare的5m限制。 ![Image](https://github.com/user-attachments/assets/8b5fd2f2-c14d-4567-a972-78e0c57f0bc4) ![Image](https://github.com/user-attachments/assets/805bf4ce-2754-45a1-bb17-dd54d4462081) 建议一:当前message已经设置了级联删除,删除邮箱会自动删除邮件,无需再手动删除邮件 ```js emailId: text("emailId") .notNull() .references(() => emails.id, { onDelete: "cascade" }), ``` 建议二:由于不用手动删除邮件,所以不用先查询出email id再删除了,直接根据expires_at删除邮箱 建议三:email表给expires_at增加索引,message表给emailId增加索引
kerem closed this issue 2026-02-26 12:17:38 +03:00
Author
Owner

@Selenium39 commented on GitHub (May 21, 2025):

优化后效果,Delete 的Rows read明显下降
Image

<!-- gh-comment-id:2896447956 --> @Selenium39 commented on GitHub (May 21, 2025): 优化后效果,Delete 的Rows read明显下降 ![Image](https://github.com/user-attachments/assets/136121d2-1a21-42e0-8c87-77c88afd8aab)
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/moemail#32
No description provided.