cylc-restart: reduce time to restart large suites

This reduces the time required to restart suites with a large number of entries in their state file.

Previously: For *each* task run a query to find out its submit_number and run a query to find out if it has a task_states table entry.

Now: For the active cycles get counts of task submissions and get a list of tasks with state entries for those cycles.

This dramatically reduces restart time from 8mins+ down to 15s for a restart of one of our operational suites.