Skip to content

Commit

Permalink
Sort bugnotes by date_submitted
Browse files Browse the repository at this point in the history
Previously they were sorted by id.

The date_submitted column is currently not indexed. I tested the new
code both with and without adding an index; the explain plan was
identical, and I did not measure any meaningful difference in query
execution time, even for bugs having a large number of bugnotes (tested
with #4286 which has 648 bugnotes).

Fixes #11742
  • Loading branch information
dregad committed Jan 23, 2015
1 parent 6ff56cd commit c951d69
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/bugnote_api.php
Expand Up @@ -423,13 +423,14 @@ function bugnote_get_all_bugnotes( $p_bug_id ) {
$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
$t_bugnote_text_table = db_get_table( 'mantis_bugnote_text_table' );

# sort by bugnote id which should be more accurate than submit date, since two bugnotes
# may be submitted at the same time if submitted using a script (eg: MantisConnect).
# Now sorting by submit date and id (#11742). The date_submitted
# column is currently not indexed, but that does not seem to affect
# performance in a measurable way
$t_query = "SELECT b.*, t.note
FROM $t_bugnote_table b
LEFT JOIN $t_bugnote_text_table t ON b.bugnote_text_id = t.id
WHERE b.bug_id=" . db_param() . '
ORDER BY b.id ASC';
ORDER BY b.date_submitted ASC, b.id ASC';
$t_bugnotes = array();

# BUILD bugnotes array
Expand Down

0 comments on commit c951d69

Please sign in to comment.