Add index to builds.state
Use the state to filter out unstarted builds

This should speed up the query, since there is now an index on
builds.state.