Digestion is time dependant. A fast rate of passage through the gut usually means less energy is gained; less nutritive value is removed from the food.
Herbivores rely on low energy fodder so have evolved an array of methods to retain the ingesta (food). They have the longer complex system with organs that specialize in either ezymatic digestion or fermentation or storing cud.
Ruminants have the longet system with a rumen for foregut fermenting followed by enzymatic digestion in the small intestines. Their intestines rum about 20 times the length of their trunk. Peccaries, often confused with the related monogastric pigs, possess the smallest relative stomach of all foregut fermenters.
Monogastric herbivores (horses, rhinos, elephants), omnivores (pigs, humans) & carnivores have a very similar stomach with digestive enzymes. The difference is monogastric herbivores then follow with a hindgut with a cecum/colon in the large intestine for fermenting fiber giving them a longer intestine than other monogastric animals. Further monogastic herbivores with intestines about 12 times their trunk have relatively rapid digestion, moving food in 18 hours that takes a ruminat 20 hours.
Omnivores vary depending on the type and energy density of their typical food. The intestine length tends to be about six times the trunk length.
Carnivores have short, enzymatic digestive systems that are monogastic. Feline intestines are only three times their trunk length.