Repository navigation
Description
Description
Content Drive is set to replace Content Search and Site Browser. We benchmarked it against both on a large production-scale dataset (~418k contentlets, ~14k folders, ~411k identifiers) running in local Docker, measuring endpoints and UI with interleaved A/B execution, warm-up discarded, 15 iterations per case, and two roles (administrator and a permission-limited user).
Content Drive comes out ahead where it matters most. Against Site Browser it wins all 34 cases — on a folder with ~4,200 listable assets Site Browser takes 7.5 s while Drive takes ~110 ms, because Drive paginates in SQL while Site Browser fetches everything and slices. In the UI, opening the portlet takes 247 ms vs 1038 ms for Content Search (−76%).
The gap is in filtered search over large folders, where Drive is up to 6× slower than an equivalent /api/content/_search query (705 ms vs 117 ms). Profiling with pg_stat_statements and Glowroot traced it to a single dominant cost, plus three smaller ones.
Root cause: the candidate-scan query enters by mod_date instead of by folder
BrowserAPIImpl builds this query to collect candidate inodes for a folder listing:
select cvi.working_inode as inode
from contentlet_version_info cvi, identifier id, structure struc, contentlet c
where cvi.identifier = id.id
and struc.velocity_var_name = id.asset_subtype
and c.inode = cvi.working_inode
and cvi.variant_id = ?
and struc.inode not in (?)
and cvi.lang in (?)
and id.parent_path = ?
and cvi.deleted = ?
order by c.mod_date asc LIMIT ? OFFSET ?The ORDER BY is on contentlet.mod_date while the selective filter is on identifier.parent_path — a different table. No index can satisfy both, so the planner enters through idx_contentlet_mod_date and hopes to find enough matches early. On a folder whose content is recent, with an ascending sort, that bet fails badly:
Limit (actual time=55.169..552.369 rows=400 loops=1)
Buffers: shared hit=909424
-> Nested Loop (rows=400)
-> Nested Loop (rows=98349)
-> Index Scan using idx_contentlet_mod_date on contentlet c (rows=104277)
-> Index Scan using idx_contentlet_vi_working on contentlet_version_info cvi
Index Searches: 104277
-> Index Scan using idx_identifier on identifier id
Filter: (parent_path = '<folder>')
Rows Removed by Filter: 1 <-- per loop, 98349 loops
Index Searches: 98349
Execution Time: 552.424 ms
104,277 contentlets scanned and 98,349 identifier probes to return 400 rows, touching 909,424 buffers.
Entering by the folder instead — materializing its identifiers first, then joining — inverts the access path. Measured on the same dataset, both variants warm:
| variant | execution time |
|---|---|
| current | 450–461 ms |
| folder-first | 101–108 ms |
4.3× faster, and verified to return the identical 400-row set (zero rows differ in either direction).
Proof-of-concept rewrite:
with folder_ids as materialized (
select id, asset_subtype from identifier
where parent_path = ? and host_inode = ?
)
select cvi.working_inode as inode
from contentlet_version_info cvi
join folder_ids fi on fi.id = cvi.identifier
join structure struc on struc.velocity_var_name = fi.asset_subtype
join contentlet c on c.inode = cvi.working_inode
where cvi.variant_id = ? and struc.inode not in (?)
and cvi.lang in (?) and cvi.deleted = ?
order by c.mod_date asc LIMIT ? OFFSET ?This query is the dominant cost in every measured case except workflow filtering: 291 ms of 393 ms unfiltered (74%), 275 ms of 379 ms with a tag filter (73%), 377 ms of 654 ms with a field filter (58%). Workflow filtering is the control that proves the point — its predicate does push into the SQL, and the same query drops to 24.6 ms.
Secondary items
| # | Item | Measured impact |
|---|---|---|
| 2 | A field filter routed to the index cannot be pushed into SQL (BrowserAPIImpl#buildFieldCriteriaESClauses skips non-INDEX buckets; #appendFieldCriteriaDBPredicates skips non-DB ones). Drive therefore fetches candidates in chunks and filters them against the index, running the scan query 4× per request instead of 1× — it scanned 3,337 candidates to return 40 results. When no DB-routed criteria are present, the existing PURE_ES heuristic could serve the query directly instead. |
4× the remaining scan cost |
| 3 | The list response carries the full WYSIWYG/long-text body of every row — 73% of a 159 KB payload for 40 rows. The Content Drive grid does not render it. Restricting the listing projection (as webAssetOptions() already does for file assets and pages, versus defaultOptions() for generic content) would remove it. |
~65 ms on folders with long-body content |
| 4 | select * from user_ where userid = ? executes 456–996 times per request. Cheap individually (~0.007 ms) so only 4–7 ms in total, but it is a per-row lookup that multiplies under concurrency. |
4–7 ms single-user; unmeasured under load |
Two correctness findings in the same query
- No host filter. The query filters on
id.parent_pathwithoutid.host_inode. On a multi-site instance where two sites share a folder path, content would be mixed across sites. Not observable on the dataset we tested (the path existed on one site only). The folder-first rewrite above adds the filter as a side effect. ORDER BYhas no tiebreaker. Withmod_datealone, ties order non-deterministically, so a row can appear on two pages or be skipped while paginating. 1.2% of rows in the folder we tested share amod_datewith another row (256 of 21,423).
Scope note
BrowserAPIImpl serves both Content Drive and Site Browser. That widens the blast radius of any change here — and it also means item 1 should improve Site Browser's 7.5 s listings as well. Site Browser regression coverage is part of the acceptance criteria below.
Acceptance Criteria
Item 1 — candidate-scan query (own PR, land first)
- The folder listing query enters by folder rather than by
contentlet.mod_date;EXPLAIN ANALYZEon a folder with ~20k children shows the folder as the driving relation - Buffer hits for a 400-row page drop by at least an order of magnitude from the ~909k baseline
- Result sets are byte-identical to the current implementation for: an empty folder, a folder of ~100 children, one of ~4k, and one of ~20k
- Deep pagination (offset 0 / 500 / 3000) returns the same rows as the current implementation at each offset
- A permission-limited user sees exactly the same rows as before the change
- Site Browser listings are unchanged in content and no slower, verified on the same folders
-
host_inodeis part of the folder predicate; a folder path present on two sites returns only the requested site's content -
ORDER BYincludes a deterministic tiebreaker; paginating a folder with tiedmod_datevalues yields no duplicated or skipped rows across pages - Re-measured against the baseline in this issue before the PR merges
Item 2 — field-filter chunk multiplier (own PR)
- When every field criterion routes to the index and no DB-routed criterion is present, the query does not loop over DB chunks
- When any DB-routed criterion is present (Tag, Relationship), behaviour is unchanged — read-your-writes is preserved per ADR-0018
- A field filter over a folder with ~20k children executes the scan query once, not four times
- Field-filter result sets are unchanged for: a text field, a date range, a multi-select, a tag field, and a category field
- Combining a field filter with a tag filter still returns correct results
Item 3 — listing projection (own PR — API contract change)
- The listing response no longer carries long-text field values (WYSIWYG, TextArea, Story Block) that the grid does not render
- Every field the Content Drive grid and toolbar actually consume is still present
- The
@Schemaannotation on the endpoint matches the reduced payload - Payload size for a 40-row page of long-body content drops by at least half
- Labelled for rollback safety, since this changes a REST response shape
Item 4 — per-row user lookup (own PR)
- User resolution during listing is batched or cached; a 40-row page issues a bounded number of user lookups rather than one per row
- Permission filtering results are unchanged for both an administrator and a permission-limited user
Overall
- Each item lands as its own PR, re-measured after each, so any regression can be reverted independently
- After item 1, re-evaluate whether items 2–4 are still needed before building them
Priority
Medium
Additional Context
Measurement method. 1,436 requests across 58 cases. Interleaved A/B execution so ambient host load affects both arms equally; warm-up iterations discarded; p50 and p95 reported; row counts recorded alongside timings so that cases where the two arms return different sets are flagged rather than compared silently. The methodology was validated by repeating a full run under load and at idle — deltas reproduced within 1–3 percentage points.
Baselines used. Site Browser (POST /api/v1/browser) for folder listings, with Drive constrained by baseTypes so both arms return the same set. POST /api/content/_search for content, as the closest endpoint-level stand-in for the Content Search portlet — that portlet is a legacy Struts portlet rendering HTML server-side and has no equivalent JSON endpoint, so it was compared at the UI level with Playwright instead.
Threshold applied. Content Drive passes a case if its p95 does not exceed the baseline's by more than 20%, with a 50 ms absolute floor so that fast operations do not fail on noise.
Not covered. Concurrency (all measurements were single-user, which matters most for item 4) and enterprise license features — the run was on a community license.
Deployment note, unrelated to performance. In the configuration we tested, the Content Drive portlet lives in a single layout granted to two administrative roles. Content editors reached Content Search and Site Browser through other layouts but had no path to Content Drive. Worth confirming that layouts and role grants are updated wherever Content Drive replaces Content Search, or non-admin users lose access.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
ihoffmann-dot commentedon Aug 21, 2026
Correction: the proposed rewrite does not generalize
Follow-up measurement invalidates the central claim in the description above. The 4.3× improvement holds only for one folder shape at one page size, and the rewrite is a regression for mid-size folders. Correcting it here before anyone builds against it.
The current query is fast on every folder except the very large one
Same dataset,
LIMIT 400(the production chunk size), both variants warm, three runs each:structurestructurestructurestructurestructurecontentletResult sets were verified identical in every row. But the planner only picks the pathological path on the largest folder — everywhere else it enters through
structureand is already fast. On the 4,188-child folder the rewrite is 3× slower. Since the overwhelming majority of folders in the dataset are small (11,827 with 1–50 children, 1,062 with 51–500, 101 with 501–5,000, 4 above that), a blanket rewrite would regress the common case to fix the rare one.The real mechanism is plan instability, not a bad query
The planner switches strategy at a
LIMITthreshold. Same folder, same query, varying only the limit:Index Scan using idx_contentlet_mod_dateIndex Scan using idx_contentlet_mod_dateIndex Scan using idx_contentlet_mod_dateIndex Scan using idx_contentlet_mod_dateSortonc.mod_dateSortonc.mod_dateBelow ~500 the planner walks the
mod_dateindex hoping to find enough matches early; above it, it gathers and sorts. The gathering plan is an order of magnitude faster on a large folder, and the crossover sits just above the production chunk size.BROWSER_DB_CHUNK_FACTORdefaults to 10, so a 40-row page requestsLIMIT 400— landing at the worst point of the slower plan.A configuration-only mitigation does not work
Raising
BROWSER_DB_CHUNK_FACTORto 25 (a 1,000-row chunk, above the crossover) and re-measuring the endpoint end to end:It buys almost nothing on the large folder and clearly regresses a mid-size one. Ruled out.
So item 1 needs reframing
The problem is not "the query is written wrong". It is that one query shape has to serve folders spanning four orders of magnitude, and the planner's estimate breaks down at the top end. Any fix has to hold across that whole range, which the CTE rewrite does not. Directions worth evaluating in the spec, none of them verified:
ORDER BYis oncontentlet.mod_datewhile the filter is onidentifier.parent_path— two tables — so this likely means carrying the ordering key alongside the folder, i.e. a schema change.Latency is bimodal, which reframes the symptom
Fifteen consecutive requests to the largest folder after 30 warm-up requests, against the same baseline:
Eleven of fifteen land at ~165 ms; four spike to ~587 ms. The baseline never moves outside 68–85 ms. So the accurate statement is ~2.2× the baseline in the common case, with ~7.8× spikes on roughly a quarter of requests — not a uniform 6× slowdown. The spikes are not extra chunk iterations (the scan query still executes 1.0× per request in this case); their cause is undetermined and worth identifying, since an occasional 600 ms response is what users perceive as intermittent hanging.
Absolute numbers depend on instance warmth — ratios do not
The same request measured 190 ms p95 on an instance that had been serving load for hours, and 544 ms p50 on a freshly restarted one, with four warm-up iterations in both cases. Thirty warm-up iterations bring the median back to 171 ms. Treat the absolute figures in the description above as warm-instance values, and prefer the ratios and the execution counts, which reproduced across every run.
Re-measured warm, the DB share holds:
user_lookupsThe two robust findings from the original description survive unchanged: the field filter runs the scan query 4× per request instead of 1×, and workflow filtering is an order of magnitude cheaper because its predicate reaches the SQL.
Item 3 has more consumers than stated
The description says the Content Drive grid does not render the long-text fields, which is true, but the grid is not the only consumer of
POST /api/v1/drive/search. It is also called by the file field in the content editor and by the asset-picker dialog, and there is a Postman collection asserting the response contract. Any projection change has to be validated against all of them, so item 3 is a wider change than "the grid does not use it".ihoffmann-dot commentedon Aug 21, 2026
Scoping detail for items 2 and 3
Two follow-up findings that narrow the estimates. Both are code reads, not measurements.
Item 3 — the projection change has one real contract dependency
Consumers of
POST /api/v1/drive/search, and whether the long-text field values matter to them:dot-content-drive.service.ts)dot-file-field.component.ts)ContentDriveResource.postman_collection.jsonThe Postman collection has 60 assertions. Fifty-nine reference
contentCount,folderCount,title,identifierandcontentType. One filters results using the content body:So the field is part of the asserted contract, even though no UI consumer renders it. That test needs updating alongside the projection change, and it is worth confirming whether reading the body there was intentional or incidental — if incidental, the change is contained; if the collection is meant to lock the full contentlet shape, the scope is wider.
Item 2 — the
PURE_ESgap is smaller than the description impliesThe description says the existing
PURE_ESheuristic "could serve the query directly". More precisely,buildPureESQuerytoday emits: system filters, working/live, variant,conhost, content-type include/exclude,languageId, the text filter, andmimeType. What it would need for the index-only field-filter case:conhostbut never byconFolder, so today it would return the whole site rather than the folderbuildFieldCriteriaESClausesalready exists and is used by the hybrid path; it is directly reusableThe part that looked expensive — translating field values into Lucene — is already written. The remaining work is the folder predicate plus the heuristic condition that selects the mode.
The tradeoff is not effort, it is freshness. Serving the listing from the index means content written moments earlier may not appear yet. That is the same read-your-writes property ADR-0018 protects by routing Tag and Relationship criteria to the database. Whether a folder listing may lag the index is a product decision, and it should be settled in the spec rather than in review.
Suggested reading of all this
Item 1 needs design work and is the one worth the spec's attention — its problem statement changed materially (see the previous comment). Items 2, 3 and 4 are each contained, but none is free: item 2 trades freshness for speed, item 3 touches an asserted contract, item 4 sits in permission-filtering code. Sequencing them behind item 1 still looks right, since item 1 changes how much the others are worth.
ihoffmann-dot commentedon Aug 21, 2026
Correction #3: item 4 was misdiagnosed — it is not an N+1, it is an undersized cache
Further investigation (two parallel agents + manual verification) found that the original diagnosis of item 4 was wrong.
Ruled-out hypotheses:
Confirmed root cause:
cache.userdotcmscache.sizeis commented out indotmarketing-config.properties, so it falls back to the defaultcache.default.size=1000. The instance has 1828 active users. The cache churns constantly, and each eviction costs not 1 query but up to 8, because the samemodUser/owneris resolved several times per row (viagetMap(),addAuditProperties,addVersionProperties, and the sort comparator).Confirmed empirically: raising the region size to 4000 (
DOT_CACHE_USERDOTCMSCACHE_SIZE=4000) droppeduser_queries per request from an average of ~688 to 1–2. Before/after, 20 requests each, same endpoint and payload.Two new findings, unrelated to the cache:
BrowserAPIImpltransforms all subfolders before trimming to the page — every discarded subfolder resolved its owner for nothing (lines ~1709 vs ~1715).filterCollectioncalls use the non-batch overload, even though the repo's own CLAUDE.md says to prefer the batch version.Open note: with the cache fixed, latency is still bimodal (17/20 requests at ~570 ms, 3/20 at ~180 ms) and
user_queries don't explain the difference. Cause not yet identified — it doesn't block this item, but it's worth investigating separately.Conclusion: item 4 does not need lookup batching. It needs (a) sizing
cache.userdotcmscache.sizeto the instance's actual user count, and (b) optionally removing redundant resolutions of the same user within a row. Both are small changes.ihoffmann-dot commentedon Aug 24, 2026
Minor correction: the host filter is not missing entirely (item 1 spike)
The item 1 spike (an investigation spec, no fix decided yet) found that my earlier claim that "the host filter is missing" from the scan query was more categorical than the code supports.
appendSiteQuery(BrowserAPIImpl.java:2113) does addid.host_inode = ?to the query — but only when!ignoreSiteForFolders && folder != nulland asitewas passed. IfignoreSiteForFolders=true, or nositeis set, the filter is not applied. I have not verified across all call paths whether that condition can occur in production with the sameparent_pathpresent on two sites. Correcting it here so it's scoped precisely, rather than my original "the filter is missing".Nothing else changes — there is still no visible solution to item 1's actual problem (query plan instability depending on the LIMIT), which remains a spike with no decision, not a ready fix.
ihoffmann-dot commentedon Aug 24, 2026
Closed in favor of 4 specific issues, linked to epic #36814:
This issue remains as the original investigation that produced those 4. All the measurement detail and corrections are still available here for anyone who needs the full context.
test(content-drive): cover deep-pagination cursor stability for tied …