For keeping it as warm as possible ideally, you only want your pump on during the hottest hours of the day say from 11pm to 3pm. That way all the water circulates and gets heated by the sun.
Running it during cooler hours bleeds off the heat that’s built up, so it’s better to let it sit still.
Of course this all goes out the window if you also have a heater on your pool.