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 e77fcd4 commit 93d3159
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/bugnote_api.php
Expand Up @@ -450,13 +450,14 @@ function bugnote_get_all_bugnotes( $p_bug_id ) {

# the cache should be aware of the sorting order
if( !isset( $g_cache_bugnotes[(int)$p_bug_id] ) ) {
# 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 {bugnote} b
LEFT JOIN {bugnote_text} 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 93d3159

Please sign in to comment.