EmerisHQ / demeris-backend

Monorepo containing all the Demeris backend code and infrastructure definitions.
GNU Affero General Public License v3.0
8 stars 1 forks source link

Cache the list of enabled chains instead of joining tables in api-server #764

Open Pitasi opened 2 years ago

Pitasi commented 2 years ago

Current api-server sql queries do something like this:

...
WHERE chain_name IN (
    SELECT chain_name FROM cns.chains WHERE enabled=true
)

While performance-wise is totally fine, it joins a table from cns with (most of the time) tables from tracelistener.

In the mindset of separating concerns, and eventually stop sharing database among services, I would love to do the following. (feel free to change the DoD if a cleaner code is possible!)

DoD:

Pitasi commented 2 years ago

Keep in mind the data from cns changes unfrequently.

maintain a global list of enabled chains

when I say this, it's also possible to maintain a list of all the chains (enabled or not) and then filter the list when requested

maintain a similar list for the ChainIDs

when I say this, if we already have the full list of chains, we can just returns the ChainID from the structs we have in memory :)