RFID systems implementing Dynamic Frame Slotted Aloha (DFSA) can adjust the number of identification rounds (slots) within an inventory cycle (frame). The usual approach to reduce the identification time of the tag population is to select the frame size attaining the highest throughput in the frame. However, it is more accurate to minimize the identification time of all the tags considering an indefinite long decision horizon. This is done in this paper by means of a Stochastic Shortest Path (SSP) formulation that incorporates capture effect and differentiation among slot durations. Our results show that the optimal policy is even faster than previous approaches.