Umbraco DataType Design
DataType's in Umbraco 4.x
I've often seem people wondering why performances is so terrible when creating Documents, particularly lots of Documents from the Umbraco API. There is a good reason for this, the design of the DataType allows anyone to be able to implement them to do almost anything.
The standard way to use a DataType is to write to the Umbraco database, but you don't have to do it that way, you can write to an XML file, call a web service or actually have no data saving.
Because of this it's up the responsibility of the DataType creator to do the CRUD operations, it's not possible to have Umbraco have some kind of a global save operation (because what if there wasn't a save!).
This does mean that there's the probability for lots of database interaction when you perform CRUD operations, but it does mean that DataTypes are infinitely flexible.
Because of this we were able to produce TheFARM Media Link Checker package for Umbraco. And I'd also hasten a guess that this flexibility also allowed the Google Analytics for Umbraco package to now allow lookups from the content item.
Comments
Morten Christensen
For the Google Analytics package I actually only use xml files, because it seemed like a better choice then to create x number of tables in the database and mix it up with Umbraco/editor content. Also because everything that you see in the Statistics section is a configuration/configurable in one way or another.
When you first have the custom content tree up and running its pretty easy to create a content picker data type, so you can use your custom data throughout Umbraco if that is what you want. So I can only agreed with you on this, as I found the DataType design to be pretty flexible.
Aaron Powell
Morten - What I was more referring to was that you have a DataType which doesn't read/ write the to the Umbraco database
Petr Snobelt
Some time ago I'm thinking about nhibernate layer for umbraco (can be performance booster with enabled cache), but I never realize it and hope that umbraco 5 have it by core team :-)
Aaron Powell
You can't use them asynchronously as they require the HttpContext. If you were seriously concerned about performance you'd write your own CRUD layer to replace Umbraco ;)
Petr Snobelt
Hi Aaron, thanks for the clarification.
Now we know reason :-), but what's recommended solution?
What about calling save on DataTypes asynchronically?