authz: remove upsert for updating user pending permissions
Created by: unknwon
We used to rely on ON CONFLICT ON CONSTRAINT
to do upsert when we do batch update on user_pending_permissions
table. However, there are reasons why the approach in this PR is better (use update not upsert):
- The primary key (
id
) ofuser_pending_permissions
table is increased rapidly every time hitsON CONFLICT ON CONSTRAINT
for no obvious benefit. (Have seen a customer with few thousand rows butMAX(id)
>80,000,000). - At the moment of "upsert", we already have
id
s on hand, could have just used it to directly update rows with theseid
s as they are primary keys.
This PR does not solve 1. entirely but at least slows down id
increment pace by half. Another half is caused by:
Merge request reports
Activity
Created by: codecov[bot]
Codecov Report
Merging #13592 into main will decrease coverage by
0.35%
. The diff coverage is80.00%
.@@ Coverage Diff @@ ## main #13592 +/- ## ========================================== - Coverage 51.79% 51.43% -0.36% ========================================== Files 1503 1503 Lines 84134 83371 -763 Branches 6910 6910 ========================================== - Hits 43573 42885 -688 + Misses 36924 36888 -36 + Partials 3637 3598 -39
Flag Coverage Δ *Carryforward flag #go 52.61% <80.00%> (-0.47%)
#integration 29.63% <ø> (ø)
Carriedforward from 9791957 #typescript 48.25% <ø> (ø)
Carriedforward from 9791957 #unit 33.94% <ø> (ø)
Carriedforward from 9791957 *This pull request uses carry forward flags. Click here to find out more.
Impacted Files Coverage Δ enterprise/internal/db/perms_store.go 78.67% <80.00%> (+0.03%)
cmd/repo-updater/repos/syncer.go 59.32% <0.00%> (-17.18%)
internal/db/dbutil/dbutil.go 14.44% <0.00%> (-6.16%)
internal/trace/httptrace.go 6.06% <0.00%> (-2.28%)
cmd/repo-updater/repos/store.go 84.32% <0.00%> (-2.09%)
cmd/repo-updater/repos/types.go 76.20% <0.00%> (-1.75%)
cmd/repo-updater/repos/observability.go 92.73% <0.00%> (-0.91%)
cmd/frontend/graphqlbackend/zoekt.go 76.08% <0.00%> (-0.82%)
internal/db/external_services.go 61.61% <0.00%> (-0.71%)
cmd/repo-updater/repos/sync_worker.go 90.32% <0.00%> (-0.35%)
... and 758 more
Please register or sign in to reply