Repository navigation
Conversation
…nchanged assets (NPF-5573) The versioned reads (config, apps, routes, templates, shared libs, router domains, auth entities) joined a GROUP BY over the whole versioning history on every call, so their cost grew with every deploy. Select the latest version id with a correlated MAX(id) per entity row instead, which is one probe of versioning_entity_idx. Cast the key to varchar on PostgreSQL: the char(255) cast resolves to bpchar there and defeats the index. Add the same index on MySQL and SQLite, where only PostgreSQL had it. Assets discovery rewrote every entity on every pass: the manifest omits the keys an app does not publish and carries dependencies as a JSON string, while the row has every column and parsed JSON, so the equality check never held. Compare only the keys the manifest publishes (an explicit null still clears a column) and keep unchanged entities on the refresh interval with an in-memory last-checked time instead of a database write.
Only the keys the manifest publishes are compared, and the manifest is already filtered by the whitelist in assetsManifestProcessor, so a loop over those keys replaces the lodash pick and mapValues.
Coverage ReportIlc/serverCommit SHA:68d0d6803d112a68f5301c4cac3aa2f66f3c55c6 Test coverage results 🧪File details
Ilc/clientCommit SHA:68d0d6803d112a68f5301c4cac3aa2f66f3c55c6 Test coverage results 🧪File details
RegistryCommit SHA:68d0d6803d112a68f5301c4cac3aa2f66f3c55c6 Test coverage results 🧪File details
|
Member
|
remove ticket ids from commits and branch please. |
stas-nc
reviewed
Oct 27, 2026
| @@ -0,0 +1,20 @@ | |||
| import { Knex } from 'knex'; | |||
| import { isPostgres } from '../util/db'; | |||
Member
There was a problem hiding this comment.
I was sure that this util was removed. Could you please remove it if not?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The registry's versioned reads (
versionedSelect, used by the config endpoint and every admin list/get) computed "latest version per entity" by joining aGROUP BYover the wholeversioninghistory on every call. That history is append-only, so the cost grew with every change and kept a shared database instance CPU-bound. The assets-discovery worker added a steady stream ofUPDATEstatements for rows that had not changed.What
registry/server/versioning/services/selectVersionedRows.ts: the latest version id is now a correlatedMAX(id)subquery per row, keyed with the existing::textcast. That is one probe ofversioning_entity_idxper row instead of an aggregate over the entity type's whole history. Same columns, sameNULLfor rows without history; everyversionedSelectcaller is unchanged.registry/server/apps/repositories/AppsRepository.ts: drop thegroupBy('v.versionId')that referenced the old join alias;GROUP BY apps.namealone is valid sincenameis the primary key.registry/server/common/services/assets/AssetsDiscovery.ts: the equality check never held, because the manifest omits keys the app does not publish and carriesdependenciesas a JSON string, while the row has every column and parsed JSON (deep-equalrejects differing key counts). Compare only the keys the manifest publishes, with an explicitnullstill clearing a column. Keep unchanged entities on the refresh interval with an in-memory last-checked time instead of a database write.Behaviour notes
UPDATEs.assetsDiscoveryUpdatedAt; nothing else reads that column.AssetsDiscovery.ts; whichever merges second needs a small rebase.Verification
versioningrows and 120 apps: the apps read went from 23.5 ms to 2.4 ms with an index-only probe ofversioning_entity_idxper row and the sameversionIdfor every row; routes with theroute_slotsjoin went from 10.8 ms to 7.4 ms.dependenciesstring vs object, stalecssBundle), an explicitnullclears a column, no manifest re-request within the interval.