What's New at CTO 2.0 ...

Oct 16

Written by: Antonio Chagoury
Thursday, October 16, 2008 

This is the first in a series of blog posts filed under the "Trimming the DNN Fat" category. I hope to add as many of these "tips and tricks" as I discover them.

In this edition we'll take a look at how the Module's Settings are being stored, used, and how they end up orphaned and therefore unnecessarily cluttering your database and as a result, you application footprint (Because DNN caches this data).

A lot of modules in the  DotNetNuke eco-system, commercial and non-commercial alike, provide configuration capabilities that allow its users to configure them and customize their functions to fit their particular business needs. DotNetNuke enables developers to store these settings through its existing APIs and data store. Developers no longer have to develop custom settings storage, data access, and business logic code in order to do provide this kind of flexibility. DotNetNuke stores this information in a SQL database table called ModuleSettings. The configuration options stored here, are in a Name-Value pair format. Depending on the size of your DotNetNuke portal and number of installed modules, this table can become quite large.

There a number of ways that data in the ModuleSettings table can be orphaned and although I do not intend on covering all the edge conditions, the most common reason is when one uninstalls a module from the Module Definitions page while the module is still configured on the some pages.

I created 2 scripts and provided them below. Use the first one to locate any orphaned module settings:

Select ModuleId From ModuleSettings 
Where ModuleId Not In(Select ModuleId from TabModules)

This second script can be used (at your own risk!) to clean the orphaned data up:

Delete From ModuleSettings 
Where ModuleId Not In(Select ModuleId From TabModules)

IMPORTANT: Please note that running the second "Delete" script will alter your data, and although I have personally performed this several times, and on several sites without ill-effects, it is always a good practice to back your data. Needless to say, I take not responsibility for any data-loss you will incur from running these scripts.

 

Tags:

4 comment(s) so far...

Re: Trimming the DNN Fat: Locate and Clean Up Orphaned Module Settings

DNN should clean up modulesettings by itself, since there is a referential integrity between the ModuleSetings table and the Modules table, with cascade delete enabled. This will cause a module's settings (as long as they are in the modulesettings table), to be deleted automatically once the module is deleted. Of course, a module is only deleted when it is removed from the recycle bin..

By erik van ballegoij on   Sunday, October 19, 2008

Re: Trimming the DNN Fat: Locate and Clean Up Orphaned Module Settings

Erik,
Thanks for the comment.

I can say for a fact that (on maybe older versions of DNN) I continuosly find tons of orphaned settings, even when the recycle bin is cleared out.
This may have been resolved in newer version of DNN but this script is still in my optimization toolbelt and still prooving to be useful.

The next time I find orphaned settings, I will update this blog post with the DNN version and other useful environmental descriptions.

By Antonio Chagoury on   Sunday, October 19, 2008

Re: Trimming the DNN Fat: Locate and Clean Up Orphaned Module Settings

Cool! Thanks.

By Joe the programmer on   Sunday, October 19, 2008

Re: Trimming the DNN Fat: Locate and Clean Up Orphaned Module Settings

Does this mean that there is a problem with the recycle bin?

By Rip Rowan on   Sunday, October 19, 2008

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 

RSS Snapshot

Antonio Chagoury - Microsoft MVPAntonio Chagoury
Software Architect, Microsoft MVP, Open Source Advocate, Golfer, Cigar Afficionado
Washington DC - USA
Company: Inspector IT, Inc.
Profiles: LinkedIn &

Antonio Chagoury - Microsoft MVP

RSS Read it in your RSS reader

 
Add to Google Reader Add to Bloglines Add to My Yahoo Add to Netvibes
 

Tag Cloud

2008   add   blog   code   community   control   data   dnn   dotnetnuke   get   google   great   group   just   know   live   may   microsoft   module   net   new   page   post   presentation   see   sharepoint   support   sure   time   use   user   way   web   windows   work  

 

    Archives

    Blog Roll