We derive recursions for the probability distribution of random sums by computer algebra. Unlike the well-known Panjer-type recursions, they are of finite order and thus allow for computation in linear time. This efficiency is bought by the assumptio
n that the probability generating function of the claim size be algebraic. The probability generating function of the claim number is supposed to be from the rather general class of D-finite functions.