How does Shape/Path optimization work


I’ve noticed that some of my queries are incredibly slow and the shape optimization usually returns a false, I’m aware that Cayley internally moves around the path and stuff - what are some of the optimization techniques Cayley uses internally? and what’s that save path in shapes? there seems to be minimal documentation on the same I can help write a good technical writeup if I can get a good insight on the same?