View Issue Details

IDProjectCategoryView StatusLast Update
0019900mantisbtattachmentspublic2015-09-06 17:37
ReporterzlowlyAssigned Todregad 
Status closedResolutionfixed 
PlatformOSCentOSOS 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

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.




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:

Related Changesets

MantisBT: master ad2d6375

2015-08-02 11:21:47


Details Diff
Improve performance of diskfile_is_name_unique()

As per user zlowly's suggestion.

Fixes 0019900
mod - core/file_api.php Diff File

Issue History

Date Modified Username Field Change
2015-07-02 23:53 zlowly New Issue
2015-08-02 18:25 dregad Assigned To => dregad
2015-08-02 18:25 dregad Status new => assigned
2015-08-02 18:25 dregad Note Added: 0051183
2015-08-02 18:26 dregad Target Version => 1.3.0-beta.3
2015-08-20 09:37 dregad Changeset attached => MantisBT master ad2d6375
2015-08-20 09:37 dregad Status assigned => resolved
2015-08-20 09:37 dregad Resolution open => fixed
2015-08-20 09:37 dregad Fixed in Version => 1.3.0-beta.3
2015-09-06 17:37 vboctoradmin Status resolved => closed