vendredi 26 mai 2023

Java implementation of splitting a Very Large Database into live and archive [closed]

I'm wondering what is the best design and most efficient, best way to implement the following in java:

I have an application in java that when a user makes a request, the app queries the database.

This large database has various tables and these tables have millions of records. I want to split the database into a live database and an archive database.

Live database contains all records that have a date which is 7 days from today's date (the date column depends on the table), records older than 7 days are archived in the ArchiveDatabase.

So whenever a request comes in from a user into our java application, we need to route the request based on the date on the request to either the LiveDatabase or the ArchiveDatabase, therefore greater than 7 days is ArchiveDatabase and less than 7 days is LiveDatabase.

My Personal approach:

A service class that receives the date and other params and forwards to a main DAO class. DAO Class has a dateChecker service which does the logic of <7 days then returns LiveDatabaseDao if >7 days then returns ArchiveDatabaseDao.

then the main DAO class uses that relevant dao to run queries using the returned DAO.

Maybe there is a better approach?

Aucun commentaire:

Enregistrer un commentaire