@Suvrutt_Gurjar, while I agree a large data set could impair performance, I suspect that isn’t the case here.
Praveen has said that the Related … columns added by AppSheet automatically are reasonably fast, even for large data sets. Were their performance a problem, it would also be evident in how long a normal full sync takes, but the poster doesn’t mention that.
My suspicion is that the delay is because the Related … columns (Related Detaile_Pedidos in this case) are virtual columns, and only updated as part of a sync. After a row is added to the Detaile_Pedidos table, there is a few second delay before the background sync pushes the update to the AppSheet server. It is at that time the server recomputes the virtual column and sends its updated value back to the app. When that updated virtual column value gets to the app, the app can recompute the new sum.
The only option as I see it is to force the Related … virtual column update from the app itself by updating a normal column of its row. An update to any normal column of a row will also prompt an update of its virtual columns. To accomplish this, you’ll need to identify a normal column of the Purchase Header table that can be changed in some trivial way, create an action that makes that change, and attach the action to the form and/or action set that adds the row to the Purchase Detail table.
Or you can just wait a few seconds for the update as you do now.