You must have army of any kind (not more then 10k archers anyway) and put archers in fort.
In some rare cases you will need to have archers even in attack, but that is really rare. Generally when battle is tough and your enemy has a small number of archers on field you can send also some archers so you will not loose morale during first 2 extra rounds. Anyway, be careful with calculator.
It's easy to understand that you don't have to send spears against a fortress without army on field but with garrison full of archers. Well, if you need honor you can do that
As you can see cavaliers and swords will be used every time, but don't hire more cavalry than 20% of your army.
P.S.
Don't look at farmers army. Their armies are not build with any strategy in mind, but only by hiring soldiers everywhere they have empty barracks