Skip to content

Commit

Permalink
Merge pull request #371 from guenaelgonnord/367-job-count-by-state-qu…
Browse files Browse the repository at this point in the history
…ery-performance

#367 - Improve job count by state query performance
  • Loading branch information
azygis committed Jun 29, 2024
2 parents fbb442e + 1f0e20c commit e69f90d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Hangfire.PostgreSql/Scripts/Install.v23.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SET search_path = 'hangfire';

DO $$
BEGIN
IF EXISTS(SELECT 1 FROM "schema" WHERE "version"::integer >= 23) THEN
RAISE EXCEPTION 'version-already-applied';
END IF;
END $$;

DROP INDEX IF EXISTS ix_hangfire_job_statename_is_not_null;
CREATE INDEX ix_hangfire_job_statename_is_not_null ON job USING btree(statename) INCLUDE (id) WHERE statename IS NOT NULL;

RESET search_path;
4 changes: 2 additions & 2 deletions tests/Hangfire.PostgreSql.Tests/PostgreSqlInstallerFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void InstallingSchemaUpdatesVersionAndShouldNotThrowAnException()
PostgreSqlObjectsInstaller.Install(connection, schemaName);
int lastVersion = connection.Query<int>($@"SELECT version FROM ""{schemaName}"".""schema""").Single();
Assert.Equal(22, lastVersion);
Assert.Equal(23, lastVersion);
connection.Execute($@"DROP SCHEMA ""{schemaName}"" CASCADE;");
});
Expand All @@ -39,7 +39,7 @@ public void InstallingSchemaWithCapitalsUpdatesVersionAndShouldNotThrowAnExcepti
PostgreSqlObjectsInstaller.Install(connection, schemaName);
int lastVersion = connection.Query<int>($@"SELECT version FROM ""{schemaName}"".""schema""").Single();
Assert.Equal(22, lastVersion);
Assert.Equal(23, lastVersion);
connection.Execute($@"DROP SCHEMA ""{schemaName}"" CASCADE;");
});
Expand Down

0 comments on commit e69f90d

Please sign in to comment.