View Issue Details

IDProjectCategoryView StatusLast Update
0036889mantisbtperformancepublic2026-04-27 09:13
Reporterraspopov Assigned Tocommunity  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.28.0 
Target Version2.29.0Fixed in Version2.29.0 
Summary0036889: Add database caching to more functions.
Description

Enabling database operation logging ($g_log_level = LOG_DATABASE;) detects duplicate database queries, including those that are completely identical and those that overlap with earlier queries in terms of the requested rows. The number of duplicates is notably large, particularly on the first page of the tracker and when custom fields are present in the projects.

Additional Information

Further investigation of the code revealed that although many requests are already cached, there are errors in some places when working with the cache, and there is no cache in others.

TagsNo tags attached.

Relationships

related to 0037098 resolvedcommunity Unnecessary token requests from the database on the issue page 

Activities

raspopov

raspopov

2026-02-20 08:36

reporter   ~0070800

PR: https://github.com/mantisbt/mantisbt/pull/2189

raspopov

raspopov

2026-03-01 03:41

reporter   ~0070808

I would also like to cache tokens_api.php calls, but this will probably require manually rebuilding the token_get() call, which returns the raw result of the database query.

dregad

dregad

2026-03-06 20:02

developer   ~0070824

Many thanks for your contribution

I would also like to cache tokens_api.php calls, but this will probably require manually rebuilding the token_get() call, which returns the raw result of the database query.

I merged the PR as it was, so feel free to open a separate one for tokens, either referencing this issue, or open a new Issue as you prefer.

Related Changesets

MantisBT: master 71404459

2026-03-06 20:00

raspopov

Committer: community


Details Diff
Add database caching to more functions

This patch dramatically reduces the number of database queries,
especially on the first page of the tracker with projects that have
custom fields.

- Added database cache to bug_get_bugnote_stats_array(),
custom_field_cache_array_rows() and filter_db_get_project_current()
- Added database negative result cache to category_cache_array_rows()
- Fixed database cache in file_bug_attachment_count_cache()
- Added cache of all relationships

Fixes 0036889, PR https://github.com/mantisbt/mantisbt/pull/2189

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Affected Issues
0036889
mod - core/bug_api.php Diff File
mod - core/category_api.php Diff File
mod - core/custom_field_api.php Diff File
mod - core/file_api.php Diff File
mod - core/filter_api.php Diff File
mod - core/relationship_api.php Diff File