I presume that you are the programmer of the script which enables/adds the link to the profile automatically.
I think the link should not be changed at all if you have used the ID of the user in the link to the profile page. But if you want to change the username in all the posts, then simply replace all the occurrences of the older username in the posts to new one when you update the username.
Hi, This would not be possible because say I have 1000 posts containing the username John. If john changes his username, it would have to update all 1000 posts. This could possible crash my database.
Seemingly you want to replace text which contains:
a) “It was user #person1234 wot said it”
With:
b) “It was user <a href=/users/1234>John</a> wot said it”
Am I right?
Well if
a) lives in your database (what you may call the “dynamic” copy), and
b) is created and cached as a text file that will deal with one-time “translations” (what you may call the cached copy)
The TTL (Time To Live) for your cache could be 5 minutes, 1 hour, 1 day - or could be forever or until some action triggers a rewrite of all you cache.
This is how I do it.
Much will depend on you insert #person1234 into the text flow, do they pick from a list? or are you in fact storing b) in your database from the get go?
You can also send a) to the client and have JS do that rewrite on the fly. It does work but I would not really recommend it.