-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ae9569
commit 726165e
Showing
3 changed files
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
726165e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introducing
BigStringEmbedded
Signum Framework has a few tables used for logging: OperationLog, ViewLog, Exception, EmailMessage, etc...
When stored in the database, this tables tend to grow big, because big chunks of text are saved for each entity, and many entities are created every day.
BigStringEmbedded
is an abstraction in Framework to store this big entities in the database first.but by starting
BigStringLogic
(in Extensions) and adding theBigStringMixin
toBitStringEmbedded
(yes! remember mixins can be added to embedded entities now!), you can move this big strings to the file system / azure storage.Some numbers
In a real application where OperationLogs where a problem
I've also Shrinked the mdf file from 50 GB to 10GB.
The funny thing is that, in Azure Storage, the 34GB have become just a few hundred MBs.
Looks like storing this big strings in the database is a very bad idea, so update you applications to BigStringEmbedded!
How to update`
Just get the latest version of Framework and Extensions and synchronize and you will see that columns like
StackTrace
have been renamed toStackTrace_Text
. If you want you can keep it like this and you won't see any important change.But if you want to get move the logs check this southwind commit: signumsoftware/southwind@d1bf677
Basically:
BigStringLogic.Start(sb)
in your Start method.MixinDeclarations.Register<BigStringEmbedded, BigStringMixin>();
BigString.Register
/BigString.RegisterAll
for each type with aBigStringEmbedded
. This method defines where each field is going to be stored. There are 4 modes, some requiring aFileTypeSymbol
:So in order to migrate and preserve the logs, I recommend to use
BigString.Migrating_FromDatabase_ToFileSystem
, sync (could take some minutes).Then make a CSharp migration that calls:
This will save every single log and move the BigStrings to the file system / blob storage. This could take a long time (hours), so better do it at night.
Once is finished, you can set it to
BigString.FileSystem
, this will remove theText
column. This operation is relatively fast.You will see that the tables are still as big as before, you need to Rebuild the indexes of the table: https://blog.sqlauthority.com/2020/03/06/sql-server-management-studio-rebuild-all-indexes-on-table/
Finally, you can consider Shrinking the mdf file if you think now is way too big for the new database. https://www.sqlserverlogexplorer.com/how-to-shrink-mdf-file/
That's it! Enjoy a small and lean database!
726165e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.