For a long enough thread, this can take quite a long time. A 614 page thread, with 15301 visible posts took ~19 seconds to merge 2 posts into it (the posts where added to the last 5-10 pages).
Looking at recalculatePostPositionsInThread, the only thing which leaps out at me is that it is doing a fetch per post and an update per changed post position. This potentially can cause a very large number of roundtrips.
It should be possible to rewrite most of that into some SQL with a temporary table to dramatically drop the number of round-trips so they do not scale as the number of posts in the thread increase.