forked from gongxuegit/tiku-backend.net
perf: optimize authorization scoreline and workers
This commit is contained in:
20073
Tiku.Infrastructure/Persistence/Migrations/20260729093312_OptimizeScorelineQueries.Designer.cs
generated
Normal file
20073
Tiku.Infrastructure/Persistence/Migrations/20260729093312_OptimizeScorelineQueries.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class OptimizeScorelineQueries : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:PostgresExtension:citext", ",,")
|
||||
.Annotation("Npgsql:PostgresExtension:ltree", ",,")
|
||||
.Annotation("Npgsql:PostgresExtension:pg_trgm", ",,")
|
||||
.OldAnnotation("Npgsql:PostgresExtension:citext", ",,")
|
||||
.OldAnnotation("Npgsql:PostgresExtension:ltree", ",,");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
"CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_scoreline_records_tenant_id_year_school_name_major_name_id ON scoreline_records (tenant_id, year DESC, school_name, major_name, id);",
|
||||
suppressTransaction: true);
|
||||
migrationBuilder.Sql(
|
||||
"CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_scoreline_records_field_values_jsonb_path ON scoreline_records USING gin (field_values jsonb_path_ops);",
|
||||
suppressTransaction: true);
|
||||
migrationBuilder.Sql(
|
||||
"CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_scoreline_records_school_name_trgm ON scoreline_records USING gin (school_name gin_trgm_ops) WHERE school_name IS NOT NULL;",
|
||||
suppressTransaction: true);
|
||||
migrationBuilder.Sql(
|
||||
"CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_scoreline_records_major_name_trgm ON scoreline_records USING gin (major_name gin_trgm_ops) WHERE major_name IS NOT NULL;",
|
||||
suppressTransaction: true);
|
||||
migrationBuilder.Sql(
|
||||
"CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_background_jobs_pending_due ON background_jobs (run_after, created_at, id) WHERE status = 'pending';",
|
||||
suppressTransaction: true);
|
||||
migrationBuilder.Sql(
|
||||
"CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_background_jobs_processing_lease ON background_jobs (lock_expires_at, created_at, id) WHERE status = 'processing';",
|
||||
suppressTransaction: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("DROP INDEX CONCURRENTLY IF EXISTS ix_background_jobs_processing_lease;", suppressTransaction: true);
|
||||
migrationBuilder.Sql("DROP INDEX CONCURRENTLY IF EXISTS ix_background_jobs_pending_due;", suppressTransaction: true);
|
||||
migrationBuilder.Sql("DROP INDEX CONCURRENTLY IF EXISTS ix_scoreline_records_major_name_trgm;", suppressTransaction: true);
|
||||
migrationBuilder.Sql("DROP INDEX CONCURRENTLY IF EXISTS ix_scoreline_records_school_name_trgm;", suppressTransaction: true);
|
||||
migrationBuilder.Sql("DROP INDEX CONCURRENTLY IF EXISTS ix_scoreline_records_field_values_jsonb_path;", suppressTransaction: true);
|
||||
migrationBuilder.Sql("DROP INDEX CONCURRENTLY IF EXISTS ix_scoreline_records_tenant_id_year_school_name_major_name_id;", suppressTransaction: true);
|
||||
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:PostgresExtension:citext", ",,")
|
||||
.Annotation("Npgsql:PostgresExtension:ltree", ",,")
|
||||
.OldAnnotation("Npgsql:PostgresExtension:citext", ",,")
|
||||
.OldAnnotation("Npgsql:PostgresExtension:ltree", ",,")
|
||||
.OldAnnotation("Npgsql:PostgresExtension:pg_trgm", ",,");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "citext");
|
||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "ltree");
|
||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "pg_trgm");
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("MassTransit.EntityFrameworkCoreIntegration.InboxState", b =>
|
||||
@@ -1113,6 +1114,10 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
b.HasIndex("TenantId", "RegionId", "SchoolId", "MajorId", "Year")
|
||||
.HasDatabaseName("ix_scoreline_records_tenant_id_region_id_school_id_major_id_ye~");
|
||||
|
||||
b.HasIndex("TenantId", "Year", "SchoolName", "MajorName", "Id")
|
||||
.IsDescending(false, true, false, false, false)
|
||||
.HasDatabaseName("ix_scoreline_records_tenant_id_year_school_name_major_name_id");
|
||||
|
||||
b.ToTable("scoreline_records", (string)null);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user