View Issue Details

IDProjectCategoryView StatusLast Update
0019900mantisbtattachmentspublic2015-09-06 17:37
Reporterzlowly Assigned Todregad  
PrioritynormalSeveritytweakReproducibilityalways
Status closedResolutionfixed 
OSCentOSOS Version6.6 
Product Version1.2.19 
Target Version1.3.0-beta.3Fixed in Version1.3.0-beta.3 
Summary0019900: move attachments from db to disk very slow
Description

There 50000+ attachments in my mantis database. While I tried to move attachments from db to disk by admin/system_utils.php, it show terrible performance which cost 2 seconds per attachment.
Finally, by digging mysql slow query log, I found that in core/file_api.php line 591(function diskfile_is_name_unique), the query sql took too much time. VIEW optimization in MySQL are still pretty primitive. Problem solved after I modified the code by put the WHERE statment into each UNION subquery as following:
$t_query = "SELECT count(*) FROM ( SELECT diskfile FROM $t_bug_file_table WHERE diskfile=" . db_param() ." UNION SELECT diskfile FROM $t_project_file_table WHERE diskfile=" . db_param() .") f";

TagsNo tags attached.

Activities

dregad

dregad

2015-08-02 18:25

developer   ~0051183

Thanks for your bug report. Could you please review and test the proposed fix based on your feedback in the following pull request:

https://github.com/mantisbt/mantisbt/pull/624

Related Changesets

MantisBT: master ad2d6375

2015-08-02 07:21

dregad


Details Diff
Improve performance of diskfile_is_name_unique()

As per user zlowly's suggestion.

Fixes 0019900
Affected Issues
0019900
mod - core/file_api.php Diff File