Superfluous query for ticket links for merged ticket id's

Hi,

if you merge ticket 2 into 1, all links are moved from ticket 2 to 1 [1].
If you later query ticket 1 for linked tickets, the link query limits by
the ticket id and RT::Ticket->Merged [2], which starts a query for
tickets that are merged into this ticket [3].

As ticket links are moved on merge, limit the RT::Ticket->_Links also by
merged ticket id’s looks unnecessary for me.

Chris

[1] rt/Ticket.pm at stable · bestpractical/rt · GitHub
[2] rt/Ticket.pm at stable · bestpractical/rt · GitHub
[3] rt/Ticket.pm at stable · bestpractical/rt · GitHub

Hi,

Hi Chris,

if you merge ticket 2 into 1, all links are moved from ticket 2 to 1 [1].
If you later query ticket 1 for linked tickets, the link query limits by
the ticket id and RT::Ticket->Merged [2], which starts a query for
tickets that are merged into this ticket [3].

As ticket links are moved on merge, limit the RT::Ticket->_Links also by
merged ticket id’s looks unnecessary for me.

I think you’re right. The code to consult merged tickets for links was added first, in 2002, here:

The code to move links on merge was added later, in 2003:

I suspect the latter change indeed made the former obsolete, but since it wasn’t breaking anything, no one ever toucheed it. I too think we can remove it.

Chris

[1] rt/lib/RT/Ticket.pm at stable · bestpractical/rt · GitHub
[2] rt/lib/RT/Ticket.pm at stable · bestpractical/rt · GitHub
[3] rt/lib/RT/Ticket.pm at stable · bestpractical/rt · GitHub

Thanks!
Shawn

I think you’re right. The code to consult merged tickets for links was added first, in 2002, here:

Merging from OurInternet · bestpractical/rt@6020dac · GitHub

The code to move links on merge was added later, in 2003:

Working more on ticket link merging; relationships now get merged; re… · bestpractical/rt@53ea766 · GitHub

I suspect the latter change indeed made the former obsolete, but since it wasn’t breaking anything, no one ever toucheed it. I too think we can remove it.

I think this could in some situations, slightly improve the performance
of the ticket search results page.
As you can add linked tickets to the ticket search result, this leads to
one additional query for each ticket, with the default search limit of
50, this are 50 additional queries.

In my case, this is more worse, because I created a custom report where
I have to inspect the links for 1000 tickets, so there are 1000
additional queries. :frowning:

So maybe this is something that is worth to go into RT 4.2?!

Should I send a PR or will you put this on your TODO list?

Chris