Always start by reading the Arch Wiki from top to bottom.
Dedicated page for Nvidia Optimus
You can find many Nvidia tutorials on this website. I will always be restricted to the hardware in my possesion.
Other users have reported this tool to work great. Let me bring it under your attention.
There are however other tools out there. Look at the Arch wiki page to learn more about them.
Any questions about the tool should be asked on his github.