diff options
| author | Ethan Lee <ethanalee@google.com> | 2025-11-13 14:51:08 -0500 |
|---|---|---|
| committer | Ethan Lee <ethanalee@google.com> | 2025-11-13 13:36:12 -0800 |
| commit | 28eed86815232e48f5e757569fcd061f858142d4 (patch) | |
| tree | fadd2816682ff4651058d980b489c186b3acf154 /internal/postgres/unit.go | |
| parent | c7fc077fc0e70e6198224f86ef70901c94919a4f (diff) | |
| download | go-x-pkgsite-28eed86815232e48f5e757569fcd061f858142d4.tar.xz | |
internal/postgres: utilize num_imports column in insert_module
- Avoid recomputing number of imports for every query in getUnitWithAllFields.
For golang/go#76284
Change-Id: I7f7d683efb1b2ff49e33681802896a65b1354d25
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/720261
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Ethan Lee <ethanalee@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/postgres/unit.go')
| -rw-r--r-- | internal/postgres/unit.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go index 33c58401..dda306ea 100644 --- a/internal/postgres/unit.go +++ b/internal/postgres/unit.go @@ -474,12 +474,7 @@ func (db *DB) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, b r.contents, d.synopsis, d.source, - COALESCE(( - SELECT COUNT(unit_id) - FROM imports - WHERE unit_id = u.id - GROUP BY unit_id - ), 0) AS num_imports, + u.num_imports, COALESCE(( SELECT imported_by_count FROM search_documents |
