I think setting the seconds low instead of high seems to work better for my setup, and adding killall Dock
restarts the dock with the new setting.
defaults write com.apple.dock autohide-delay -float 2; killall Dock
I'm on MacOS Sonoma with a widescreen monitor arranged on top and laptop at the bottom. Even with the monitor set as primary display, it always seems to start the dock on the bottom when I sleep/restart/open laptop, and setting it to 9999999
makes moving it back take longer. Setting to 1-2 seconds means it will instantly move to the main monitor when the cursor is at the bottom.