Normally, in the SF summertime, the prevaling wind is east by mid-afternoon and continues strong well into the evening. Thus the city hardly ever heats up or experiences bad air until August, when the weather system changes and the winds calm down.
This also leads to a distinct pattern with wildfire smoke; so long as there isn't a buildup over the ocean, the city gets some relief until there's a day with no wind, at which point it gets as socked in as the rest of the Bay. Last year was particularly bad since the ocean air eventually did get polluted and it circulated until precipitation cleared it. So far things are holding up better this year, but we have a few months to go.