Skip to content

Commit

Permalink
Fixes indexing error when sending large payload content beyond Postgr…
Browse files Browse the repository at this point in the history
…es Include design. (#1619)
  • Loading branch information
yang-xiaodong committed Feb 4, 2025
1 parent 0794191 commit 6b88bc5
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/DotNetCore.CAP.PostgreSql/IStorageInitializer.PostgreSql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected virtual string CreateDbTablesScript(string schema)
);
CREATE INDEX IF NOT EXISTS ""idx_received_ExpiresAt_StatusName"" ON {GetReceivedTableName()} (""ExpiresAt"",""StatusName"");
CREATE INDEX IF NOT EXISTS ""idx_received_Version_ExpiresAt_StatusName"" ON {GetReceivedTableName()} (""Version"",""ExpiresAt"",""StatusName"");
CREATE TABLE IF NOT EXISTS {GetPublishedTableName()}(
""Id"" BIGINT PRIMARY KEY NOT NULL,
Expand All @@ -90,22 +91,8 @@ protected virtual string CreateDbTablesScript(string schema)
);
CREATE INDEX IF NOT EXISTS ""idx_published_ExpiresAt_StatusName"" ON {GetPublishedTableName()}(""ExpiresAt"",""StatusName"");
CREATE INDEX IF NOT EXISTS ""idx_published_Version_ExpiresAt_StatusName"" ON {GetPublishedTableName()} (""Version"",""ExpiresAt"",""StatusName"");";

DO $$
DECLARE
major_version INT;
BEGIN
SELECT split_part(current_setting('server_version'), '.', 1)::int INTO major_version;
IF major_version >= 11 THEN
CREATE INDEX IF NOT EXISTS ""idx_received_Version_ExpiresAt_StatusName"" ON {GetReceivedTableName()} (""Version"",""ExpiresAt"",""StatusName"") INCLUDE (""Id"", ""Content"", ""Retries"", ""Added"");
CREATE INDEX IF NOT EXISTS ""idx_published_Version_ExpiresAt_StatusName"" ON {GetPublishedTableName()} (""Version"",""ExpiresAt"",""StatusName"") INCLUDE (""Id"", ""Content"", ""Retries"", ""Added"");
ELSE
CREATE INDEX IF NOT EXISTS ""idx_received_Version_ExpiresAt_StatusName"" ON {GetReceivedTableName()} (""Version"",""ExpiresAt"",""StatusName"");
CREATE INDEX IF NOT EXISTS ""idx_published_Version_ExpiresAt_StatusName"" ON {GetPublishedTableName()} (""Version"",""ExpiresAt"",""StatusName"");
END IF;
END $$;
";
if (_capOptions.Value.UseStorageLock)
batchSql += $@"
CREATE TABLE IF NOT EXISTS {GetLockTableName()}(
Expand Down

0 comments on commit 6b88bc5

Please sign in to comment.