Imported database very slow on a simple query
Here are the principles.

(I assume id is the primary key of the table and the table is InnoDB.)
SELECT count(id) FROM payments; will read the entire table.  Or it may read some secondary index, which necessarily includes the PK.
The first time you touch a table, the data is sitting on disk must be read into RAM for processing.  Since it needs to read the entire table, that could take some time.
If you run another query on the same table, it can skip the I/O.  This is often a factor of 10 faster.
If the first query used a secondary index, but the WHERE is_held = True needs was not involved in that index, then this query will need to read the entire data BTree.  One of your tables apparently had it cached already (0.32s) and the other did not (37s).
Don't use COUNT(id) unless you need to avoid counting any rows with id IS NULL, which cannot happen.  Instead, use simply COUNT(*).
INDEX(hash_id, id) would make some of your queries run faster because they could run entirely in that index's BTree.
Upgrading/downgrading the server is unlikely to change performance -- unless the table is bigger than the buffer_pool.  In this case, the table cannot be cached to make the second query fast.

For further discussion, please provide SHOW CREATE TABL, SHOW TABLE STATUS, and the value of innodb_buffer_pool_size.