Skip to content

Commit

Permalink
Merge pull request #9261 from aaannz/errata_optimizations
Browse files Browse the repository at this point in the history
Retracted errata query optimizations
  • Loading branch information
deneb-alpha authored Sep 11, 2024
2 parents 1bfe3f3 + e8f5491 commit 31de9cf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ DELETE FROM rhnOrgErrataCacheQueue WHERE org_id = :org_id
<!-- -->
<query params="channel_id">
INSERT INTO rhnServerNeededCache (server_id, package_id, channel_id)
( SELECT DISTINCT
( WITH retracted_packages AS (
SELECT DISTINCT ep.package_id AS pid, sc.server_id AS sid
FROM rhnserverchannel sc
JOIN rhnchannel c ON c.id = sc.channel_id
JOIN rhnchannelerrata ce ON ce.channel_id = c.id
JOIN rhnerrata e ON e.id = ce.errata_id
JOIN rhnerratapackage ep ON ep.errata_id = e.id
WHERE e.advisory_status::text = 'retracted'::text
AND ep.package_id in (%s))
SELECT DISTINCT
S.id as server_id,
P.id as package_id,
:channel_id as channel_id
Expand All @@ -118,7 +127,7 @@ DELETE FROM rhnOrgErrataCacheQueue WHERE org_id = :org_id
SC.channel_id = :channel_id
AND SC.server_id = S.id
AND p.id in (%s)
AND NOT EXISTS (SELECT 1 FROM suseServerChannelsRetractedPackagesView WHERE sid = S.id AND pid = P.id)
AND NOT EXISTS (SELECT 1 FROM retracted_packages WHERE sid = S.id AND pid = P.id)
AND NOT EXISTS (SELECT 1 FROM suseServerAppStreamHiddenPackagesView WHERE sid = S.id AND pid = P.id)
AND p.package_arch_id = spac.package_arch_id
AND spac.server_arch_id = s.server_arch_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- use custom select instead of errata view for better performance
(bsc#1225619)
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
--

CREATE OR REPLACE VIEW suseServerChannelsRetractedPackagesView AS
SELECT DISTINCT p.id AS pid,
s.id AS sid
FROM rhnserver s
JOIN rhnserverchannel sc ON s.id = sc.server_id
SELECT DISTINCT ep.package_id AS pid,
sc.server_id AS sid
FROM rhnserverchannel sc
JOIN rhnchannel c ON c.id = sc.channel_id
JOIN rhnchannelerrata ce ON ce.channel_id = c.id
JOIN rhnerrata e ON e.id = ce.errata_id
JOIN rhnerratapackage ep ON ep.errata_id = e.id
JOIN rhnpackage p ON p.id = ep.package_id
WHERE e.advisory_status::text = 'retracted'::text;

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- remove superfluous joins from errata view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE OR REPLACE VIEW suseServerChannelsRetractedPackagesView AS
SELECT DISTINCT ep.package_id AS pid,
sc.server_id AS sid
FROM rhnserverchannel sc
JOIN rhnchannel c ON c.id = sc.channel_id
JOIN rhnchannelerrata ce ON ce.channel_id = c.id
JOIN rhnerrata e ON e.id = ce.errata_id
JOIN rhnerratapackage ep ON ep.errata_id = e.id
WHERE e.advisory_status::text = 'retracted'::text;

0 comments on commit 31de9cf

Please sign in to comment.