I've seen people say both that you're supposed to tie it up and that you're supposed to leave it loose before going to bed to prevent tangling and I don't know which is true.
Different sorts of hair tangle under different conditions, so the answer to which is true is "both". It's not going to be consistent between all people.
When I actually care about tangling (rarely, even at its worst my hair doesn't tangle badly -- my bedhead is less rat nest and more anime or mad scientist), my best luck with something I can actually manage has been with a
high ponytail, getting it so it's over the back of whatever pillow-equivalents I'm sleeping on and not, y'know, underneath me.
... my best luck with assistance has been a tight braid earlier in the day and just not letting it loose to sleep. Never quite gotten the hang of braiding it without help, though. Something about the process just
seriously screws with my motor control, and despite trying several dozen times over the years, both with and without help, it's just never stuck
Any case, yeah, the least finicky way of handling it is to just brush it out more than once a day. That's true with or without putting it into some kind of tail. There's also chemical solutions (hair spray, conditioner, etc.), but... in my experience, the stuff that works tends to make your hair either be pretty unmanageable or feel fucking terrible -- most conditioner-direction stuff I've tried basically turns my head into an afro (hair gets annoyingly fluffy =_=), and hairspray ends up with a head of
straw, which is just miserable.
I'd just brush more often unless it's getting pretty desperate. If it
is getting desperate, get a spread of options and try them all to see what works best. Hair care can be pretty personalized.