Producing a 'live' performance measure for jockeys and trainers has been a real headache for me.
I tried various approaches but they involved fiddly programming and tended to produce output (whether rolling win percentages or something else) that were unhelpfully volatile.
I've ended up simply producing a calendar year 'look-up' table of jockey and trainer performance statistics. This seems to work as well as anything else and is quite simple to program. The core code I used the populate the 'jockey_lookup' table is:
insert into `smartform`.`jockey_lookup`
select
`run`.`jockey_id` AS `jockey_id`,
year(`rac`.`meeting_date`) AS `reference_year`,
count(`run`.`runner_id`) AS `count_of_runners`,
sum((`run`.`distance_beaten` is null) * (`run`.`finish_position` = 1)) AS `count_of_winners`
from
(`smartform`.`historic_runners` `run`
join `smartform`.`historic_races` `rac`)
where
`run`.`race_id` = `rac`.`race_id`
and `run`.`jockey_id` is not null
group by `run`.`jockey_id`,year(`rac`.`meeting_date`)
having ((`count_of_winners` >= 5) or (`count_of_runners` >= 50));
update `smartform`.`jockey_lookup`
set `reference_year` = `reference_year` + 1;
When analysing a race I can then look up the reference jockey win percentage (calculated as count_of_winners / count_of_runners) using the jockey_id and reference_year as join variables.
I've used the same approach for trainers, and produce separate look-ups for flat and national hunt.
Hope this helps