Re-fix pgsql refresh stream scripts

Refresh streams are supposed to be run in a single transaction.

Use the database to keep track of which data set has been used by
keeping a counter.  Have each refresh stream grab a dataset identifier
as it is executed and generate the dataset's files on demand.