Depends on the type of hanging:
i)Drop hanging full suspension
-> If weight is known and the drop length and subsequently the rope length is calculated correctly then there is absolutely no pain, as your neck breaks and you go instantly into deep coma state, then a few more minutes until the brain is dead and that is it.
ii) Full suspension
-> When using full suspension without a drop cause of death is ,due to your whole body weight carried by your throat and neck, asphyxiation by compressed airway which is probably pretty painful for approximately 60-120 seconds until you finally lose consciousness, then additional 15 or 20 minutes (as your body keeps breathing) until the lack of oxygen is great enough for the brain to die and your body finally shuts down completely
iii) Partial Suspension
-> If done right there shouldnt be any pain at all. Assuming you were able to block your carotid artery, but not your jugular veins and the airway, so that you become unconscious upon applying pressure within ~15 seconds thus then letting go and sinking into your hanging setup unconsciously and then it is the same as for full suspension, although it will take some more time for you to be dead, as the pressure is not that high due to it being partial suspension (less body weight is compressing your throat and neck).
So after all, full suspension with a proper drop I would rate as the most painless and safest method. Partial suspension done correctly is also very painfree, but it takes the longest time out of the 3 methods and again you shouldnt be found in the middle of any hanging. Only full suspension seems like a bit of painful torture but then again it does the job for sure, because if you prepare correctly you cant escape. If you did your setup properly and are not disturbed all methods will work. Usually when people fail it is human error e.g. rope setup not stable enough, they had people in the vicinity and got found or they do it indoors, not free hanging, with access to anything they can grab onto to save themselves. The survival instinct is so strong the body even tries to grab something and pull up while you are already half gone.