How can I set Keycloak user id as static?

Hi all. I am using Keycloak for authentication.

I used the user id in the access token as a user identity and stored it in some tables when users did some actions. I have some counters relying on user-id.

But recently, I found that the Keycloak user id is dynamic and it is changed after some time( I am not sure how long a user-id is kept) that making my counters counted improperly.

So I wonder is there a way that we set the user id static? And how can I get the user email from the user-id that had been changed in the past?

I am really appreciated your help and suggestions. Thank you so much.