If a person has a doubt during prayer about whether they have performed a rukn (pillar) or not, and they keep thinking for the duration of performing one rukn, i.e., the time it takes to say 'Subhan Allah' three times, engaging neither in recitation (Qira'at) nor in remembrance and glorification (Dhikr and Tasbeeh), then in this case, Sajdah Sahw (prostration of forgetfulness) becomes obligatory upon them. And if they continued praying while thinking, then Sajdah Sahw will not be obligatory. (Book: Aham Masail / Pg: 72)