If you give the dry pasta a gentle stir for a few seconds after adding to the water it prevents sticking during cooking. This type of adhesion is called making "squids" with spaghetti because one end will stick and the other frays. Don't stir so hard it breaks the noodles or you are gonna have little 2 inch noodles and Nonna is gonna make fun of you. If you are breaking them any way or cooking spaghetti that is not fully immersed in water you need a bigger pot.
A similar problem is when pasta sticks together after completely draining and cooling. You can do as others have suggested and toss the freshly cooked pasta with a little olive oil to prevent sticking. If it is already stuck or you don't like extra oil pour water over the drained pasta and it will loosen readily after a light toss. If you are serving immediately after loosening make it hot water and it doubles as a re heating method



