I think there is still some missing information here.
If this is local (e.g. prefect server), where is this hosted?
How large is the database, how much data are in the flow run logs
Are you running sqlite, or postgres?
Timed out api error is basically meaning that the database isn’t satisfying the request before the timeout value, which could be a factor of # of simultaneous connections / transactions, database usage, network connectivity to the database