-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added index and avoid json convertion (#256)
* - Added index - Avoid json convertion in db layer * Add empty line at the end of file --------- Co-authored-by: Henning Normann <[email protected]> Co-authored-by: Terje Holene <[email protected]>
- Loading branch information
1 parent
6e367c1
commit 0e00462
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/Altinn.Notifications.Persistence/Migration/v0.07/01-setup-indexes.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX IF NOT EXISTS notifications_processedstatus_requestedsendtime ON notifications.orders (processedstatus, requestedsendtime) INCLUDE (_id); |
17 changes: 17 additions & 0 deletions
17
src/Altinn.Notifications.Persistence/Migration/v0.07/02-setup-functions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
DROP FUNCTION IF EXISTS notifications.getorders_pastsendtime_updatestatus(); | ||
CREATE FUNCTION notifications.getorders_pastsendtime_updatestatus() | ||
RETURNS TABLE(notificationorders jsonb) | ||
LANGUAGE 'plpgsql' | ||
AS $BODY$ | ||
BEGIN | ||
RETURN QUERY | ||
UPDATE notifications.orders | ||
SET processedstatus = 'Processing' | ||
WHERE _id IN (select _id | ||
from notifications.orders | ||
where processedstatus = 'Registered' | ||
and requestedsendtime <= now() | ||
limit 50) | ||
RETURNING notificationorder AS notificationorders; | ||
END; | ||
$BODY$; |