Get/Set workflow state var from child activity

I have a child workflow, which further has activities.
For one activity I am writing rows to a db, and
on activity retry, do not want to start from 0 and
have a checkpoint.

Where can i save this checkpoint and set/get from the
activity.

Whats max number of rows you have to write? Heartbeating after each row (with heartbeat details) and getting last heartbeat details in your activity code to resume in case of activity timeout can still cause duplication due to heatbeat throttling, but can help. Alternatively you could maybe check rows written at the beginning of your activity to know where to resume from or write last written record info to db that can use as reference. For smaller max number of rows you could consider doing each write as separate activity/local activity

This can be in 50K-60K.
Can I use heartbeat after writing a batch,
lets say 1-5K. My db is BQ.

Batching is good idea imo but would write batch num to db after each for use case as it will be hard to set heartbeat timeout imo to match duration of each batch (to make sure worker sends heartbeat after each one is processes). Then on activity start check batch num to know if need ro continue.