There are occasions when a 'real' race has to be filmed.
It is still, as ruffdove says, filmed in parts & in such a way that you never see it all at once.
Stunt jockeys & horses can be used to ensure horses stay in the correct relative places & positions. Editing is used to infill in your imagination the events as they unfold.
I had the privilege of spending 3 days at Windsor racecourse, cleverly pretending to be Epsom, for the recreation of the famous Emily Davidson suffragette protest in front of the King's horse at the 1913 Epsom Derby.
Though film was relatively new at the time, the spectacle the race would have provided even on an ordinary Derby day was sufficient to bring the world's cameras to it - so when Davidson was knocked over & killed, the scene was caught on film, moving & stills, from many angles.
Having so much footage of the actual event meant the movie recreating it had to be convincing. In the final cut, there is actually very little you see of it, but each element is actually accurate. Even parts of the crowd are dressed & placed in the right place to match known images - including the racecourse doctor, who happened to be right at the point where she fell, on the day [this was discovered from stills and later pieced together].
That was me ;) I think I'm on screen for about half a second in all, but I was there.
The race itself was filmed from many angles, from 8 movie cameras at once, which made it a fantastic feat of organisation, let alone placing 600 supporting artists & principal cast. Of course, all the intervening close-up action & dialog, even if you see a horse in the background, placement is less vital, but in the wide shots, everything needed to look right.
The stunt itself was done in several sections -
A stunt woman to run out in front of a galloping horse [this in itself took some careful timing, as Davidson on the day ran out as only half the field had passed - several horses managed to avoid her. The King's horse was 3rd to last.
A cutaway to the actress's reaction to the horse bearing down [done without the horse there, of course]
A dummy stood in place for the actual impact.
A large soft 'crash' patch dug into the ground where the horse needed to fall, covered in grass, which all the other horses had to not run through.
A stunt jockey and a horse that was trained to fall on command.
For a movie to actually get something like 6 minutes' footage out of 3 days' filming in itself was quite a feat. Two separate film units & 8 cameras were necessary to work that fast.
Original historic footage -
Analysis -
Italian dub of the entire movie [not sure how long that will survive before being taken down]. The race starts at 1h30m. For all the detail that went into the reconstruction, most of the action is focussed on the movement of the three main protagonists as they move through the crowd.
& just for fun… me ;)
As the horse fell…

…and tending to Emily, centre frame...
