mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
perf: schema indexes (#3446)
This commit is contained in:
@@ -98,6 +98,12 @@ try {
|
|||||||
ChatItemSchema.index({ time: -1, obj: 1 }, { background: true });
|
ChatItemSchema.index({ time: -1, obj: 1 }, { background: true });
|
||||||
// timer, clear history
|
// timer, clear history
|
||||||
ChatItemSchema.index({ teamId: 1, time: -1 }, { background: true });
|
ChatItemSchema.index({ teamId: 1, time: -1 }, { background: true });
|
||||||
|
|
||||||
|
// Admin charts
|
||||||
|
ChatItemSchema.index(
|
||||||
|
{ obj: 1, time: -1 },
|
||||||
|
{ background: true, partialFilterExpression: { obj: 'Human' } }
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
@@ -79,8 +79,10 @@ const UserSchema = new Schema({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// login
|
// login
|
||||||
UserSchema.index({ username: 1, password: 1 });
|
UserSchema.index({ username: 1, password: 1 }, { background: true });
|
||||||
UserSchema.index({ createTime: -1 });
|
|
||||||
|
// Admin charts
|
||||||
|
UserSchema.index({ createTime: -1 }, { background: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ try {
|
|||||||
// timer task. clear dead team
|
// timer task. clear dead team
|
||||||
// UsageSchema.index({ teamId: 1, time: -1 }, { background: true });
|
// UsageSchema.index({ teamId: 1, time: -1 }, { background: true });
|
||||||
|
|
||||||
UsageSchema.index({ time: 1 }, { expireAfterSeconds: 180 * 24 * 60 * 60 });
|
UsageSchema.index({ time: 1 }, { background: true, expireAfterSeconds: 720 * 24 * 60 * 60 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user