Orthopedic surgeries are risky procedures for the elderly, as they often require a several hours of general anesthesia. If you have dementia on top of advanced age, the risks of
complications does increase. Many people have issues with anethesia, like waking up confused or being overly sedated. Even after surgery, you could develop post-operative delirium (confusion) from the anethesia, making the recovery time difficult.
You should also consider the post-surgical period, as this can be difficult as well. Many older people need to be in a short-term care facility, as they need hours of rehab therapy to recover from this kind of surgery.
I would recommend that you talk with your doctors about this, and see if they think this is something for you to consider doing. I would recommend that you should exhaust all the possible alternatives, like physical therapy and pain medications, before you choose surgery under general anesthesia.