I have read that batch gradient descent forces this summation at every step of the update, which makes it time consuming.
But if we have the following hypothesis function: $$h(x^i) = w_0 + w_1x^i$$
Then the update rules become:
$$w_1 = w_1 - \alpha/N\sum_{i=1}^n (y^i - w_0 - w_1x^i)x^i$$
$$w_0 = w_0 - \alpha/N\sum_{i=1}^n (y^i - w_0 - w_1x^i)$$
which can be represented as:
$$w_1 = w_1 - \alpha/N(\sum_{i=1}^n y^i*x^i - w_0\sum_{i=1}^nx^i - w_1\sum_{i=1}^nx^i*x^i)$$
and
$$w_0 = w_0 - \alpha/N(\sum_{i=1}^n y^i*x^i - N*w_0 - w_1\sum_{i=1}^nx^i)$$
In this rule, the following can be precomputed
$$\sum_{i=1}^n y^i*x^i$$
$$\sum_{i=1}^n x^i$$
$$\sum_{i=1}^n x^i*x^i$$
So we don't need to perform the summation at every individual update of the parameter.
Then why do we need stochastic gradient descent?