Not sure If I understood you question correctly but here is what I would do if I need to derive “extra database” information after hitting the “base database”.

Lets say I have two extra databases out of which I would fetch the data from anyone depending on the information from base database. I would put the logic of connecting to the extra databases and connection to the main database together instead of making the connection in the middle of a request. Creating connection to databases is expensive and can slow down the response time considerably.

This is similar on how we would implement application level sharding of any database. This is also similar to an app which requires connection of two different databases like mySQL and Redis. Both the connections are made at the server start time.

Hope this helps. Thank you for encouraging words

Senior Staff Engineer @freshworks. Ex-McKinsey/Microsoft/Slideshare/SAP, Tech Enthusiast, Passionate about India. Opinions are mine

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store