Before modifying the database structure, and its impact on applications, I suggest an analysis of what is causing the slowness. They may be outdated statistics, some query that needs to be optimized, fragmented or missing indexes etc. In short, typical database administration tasks.
After the analysis, it may be indicated the creation of additional indices. For example, if there is a high number of queries in the "sale" table per period, then it is likely that the creation of index by the ven_Data column will optimize these queries. Of course, in addition to the ven_Data column, it is necessary to evaluate cover columns that should be in that index.
In the sales tableProduct seems to me that should be reevaluated what will compose the index clustered. The vpr_ID column as the index key clustered, seems useless to me. It could even be kept as a primary key, but on an index nonclustered. Or better yet, just declare that column as Unic.
Among the several candidate keys of the "salesProduct" table, perhaps the ven_ID column is the ideal to be chosen as index key clustered. It can be a simple key, accepting duplicities, or a composite key (ven_ID + vpr_ID), exclusive (no repetitions).
The suggestion is that, before thinking about modifying the database structure, find the current bottlenecks.
Regarding the physical space occupied, analyze how much each column occupies. For example only, the column Table quantity "salesProduct" is declared as int. That is, it occupies 4 bytes and accepts values of up to 2 million and little. Did any book have more than 32,000 copies sold in the same transaction? If the quantity of each item sold is less than 32 thousand units, you may declare the column as smallint, that then the column will occupy half of the space (2 bytes).
The same reasoning for the fun_ID column in the "sale" table, which is also stated as int. Are there more than 32,000 employees in this bookstore?! Of course not! This column could be declared as smallint (up to about 32 thousand employees) or even tinyint (up to 255 employees).
The "sale" table contains the date of sale but does not include the time. If it is necessary to also record the time of sale, evaluate the use of the type smalldatetime. The guy date occupies 3 bytes and smalldatetime occupies 4 bytes.
These are details that, in the end, make the difference in performance.
Felipe, should the data that is copied to the respective backup tables be deleted from the original table? If yes, you will need to reprogram the app to query both active and archived data.
– José Diz
Felipe, what is the approximate number of lines in the tables "sale" and "salesProduct"?
– José Diz