Developer forum

Forum » CMS - Standard features » Exceeding max row size problems

Exceeding max row size problems

Peter Leleulya
Reply

Hi there,

I'm having issues with an itemtype.
This one is attached to an area as extra area configuration.
It has a number of text field controls and some page selection controls.
The text field controls create an nvarchar(255) database field.
It being an Nvarchar means 255 times 2, so adding about 15 text fields will exceed the maximum row size and you wil get a SQL error on screen!

Maximum row size isn't something we can change, but when we could choose the length of the nvarchar field it would be a start. Maybe a text field (nvarchar(255)), small text field (nvarchar(100)) and a tiny text field (nvarchar(50))  or someting in that direction ....

When checking the rowsizes of the database we are currently working with we noticed a number of tables exceeding the max rowsize. This is a potential danger and should be looked at by Dynamicweb I think.
Here a list of these tables.
I deleted a bunch of fields in my item, so it is not in the list, but it was up there ...

name

NumCols

FixedDataSize

NumVariableCols

MaxVarSize

NullBitmap

VarDataSize

RowSize

EcomOrders

127

104

124

19696

18

19946

20072

AccessUser

77

9

71

17913

12

18057

18082

EcomProducts

86

692

74

15187

13

15337

16046

Page

103

17

89

13543

15

13723

13759

DBPubView

46

18

31

10204

8

10268

10298

EcomRmas

35

210

30

9522

7

9584

9805

Statv2Session

65

5

63

9364

11

9492

9512

Area

49

8

44

9140

9

9230

9251

LegendLayout

23

4

22

9052

5

9098

9111

OMCExperiment

26

4

25

8917

6

8969

8983

DealerSearchDealer

25

5

23

8826

6

8874

8889


Replies

 
Hans-Henrik Stefansen
Reply

Hi Peter,

Currently the definition of itemtypes on the database is very simple and not so optimized with the limitations of SQL Server in mind.

We have already recieved a feature-request to provide the ability to override and/or choose the datatype and size for fields on the database.
When it will be implemented is not planned at the moment I'm afraid.
I have attached your request to the task, so we know it is needed by you.

In the meantime to workaround the issue, I suggest you define the itemtype in Dynamicweb with the text-fields needed, and then directly on the table in the database, change the length of the nvarchar-columns to fit your needs.
It should not give any problems as long as you do not change the datatype itself.

Regarding the exceedance of the max row size for some of the tables in the database, this is something we are aware of.
Eventhough you recieve a warning from the SQL Server, as long as the actual row size do not exceed 8,060 bytes no errors will thrown and indexing and so on should function correctly.

We are constantly working on improving performance and the overall design of the database, and the variable-length column sizes is also something we are looking at, since it can create issues with providing optimal default indexing of the database.

Best regards,
Hans-Henrik

 

 
Peter Leleulya
Reply

Thanks Hans-Henrik,

I already tried changing some nvarchar(255) fields to nvarchar(50) but that didn't work, they automaticly were changed back to 255.

Or could that be caused by the Itemtypes synchronizations settings under file manager which were set to "Files"? (I changed that to "Database" just a few minutes ago on recommendation by Nicolai).

 
Hans-Henrik Stefansen
Reply

Hi Peter,

I just tested the different scenarios you are able to set up synchronization settings for itemtypes.
I'm afraid that all of them will update the table schema on the database and overwrite any changes you've made on the database.

 

 
Peter Leleulya
Reply

That's what I experienced too ...
So there is no real solution/workaround at the moment other than changing the textbox to long text or remove them all together ...
Long text creates an nvarcher(max) which includes a pointer in the row, but not the data. But this control renders a text area in stead of a text field, which is not desirable ...

 
Hans-Henrik Stefansen
Reply

We do not have a workaround at present other than, as you point out, using the Long Text field type instead.
But it will create a textarea when rendering in the frontend, but you could opt to control the look and feel by CSS and JS making it look an act as a textbox.

I just changed to look of a textarea to look a bit like a textbox with a few lines of CSS

textarea.item-field {
 overflow: hidden; //hides the scrollbars
 max-height: 15px; //restricts the height
}

 

 
Peter Leleulya
Reply

Thanks Hans-Henrik, I'm hoping the existing feature request will get pickud up soon ;)
 

 
Hans-Henrik Stefansen
Reply

You're very welcome and hopefully it will - Items are focus area for us.

 
Hans-Henrik Stefansen
Reply
This post has been marked as an answer

Hi Peter,

Just had a small talk with Nicolai, and he enlightened me to the fact that editors for items are Add-In based.
So you can create one of your own and combine the use of nvarchar(max) on the database and rendering a textbox in the frontend.

I've attached a sample project with a Textbox-editor limited to 100-characters.

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Hans-Henrik (and Nicolai),

Great, thanks for shharing that! In case someone needs it, here's the code for the editor in C# (you need references to the Dynamicweb.dll and Dynamicweb.Extensibility.dll assemblies)

using Dynamicweb.Content.Items.Editors;
using Dynamicweb.Content.Items.Annotations;

namespace MyItems.ItemEditors
{
  [Editor("Text 100")]
  public class String100Editor : StringEditor
  {
    public String100Editor()
    {
      MaxLength = 100;
    }
  }
}


Imar

 

 
Peter Leleulya
Reply

OK, I tested this and the add-in works, but this would mean I will get a bunch of nvarchar(max) datatype fields for short text values.
I tried to figure out if there is a way to create a nvarchar(20) or something like that using add-ins, but can't find a way.
Is there a way to achief that in your opinion ??

 
Hans-Henrik Stefansen
Reply

Hi Peter,

I have taken a look at how the datatype is determined, and item fields with string-based editors are always converted to NVARCHAR(max) column on the table in database.
Only the TextEditor is created as NVARCHAR(255).

Currently there is no way of controlling the length of the NVARCHAR-column, since we do not use the MaxLength property of the editor when synchronizing the table.
And you have no way of overriding the behavior, so you will not be able to workaround it.

But if you don't use columns as predicates in queries against the table on the database, it shouldn't become an issue for you that the datatype is NVARCHAR(max). You will still have the possibility of including the NVARCHAR(max) columns in sql-indexes and thereby improving query-times.

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Innovadis kept having issues (they got an error when saving the Site settings). I looked into this, and here are some of my findings:

  • I could reproduce the problem easily on a copy of the site on my local machine. Whenever I saved the area settings, I would get the aforementioned error.
  • I could easily insert new records in the same table using SQL Server Management Studio.
  • When updating the existing row in SQL Server Management Studio it would fail too.
  • When I created a new table in a new database using the CREATE TABLE statement that Peter supplied, I could successfully insert new records in that table.
  • I could also insert records with maxed data, resulting in a bigger row size than the current data in ItemType_ExtraAreaConfigurations.

 

All this led me to believe that this was not a bug in Dynamicweb, but an issue in the SQL Server database.

 

After a lot of Googling and experimenting I found this: https://www.simple-talk.com/blogs/2009/02/19/why-should-i-rebuild-a-table-after-dropping-or-adding-a-column/ which explains how a deleted column can still be present in the index and take up space, adding up to the total size. So, as a simplified example, if you create two columns with a size of 3500, insert the maximum amount of data and then delete the columns, the new maximum size for the existing record(s) in that table is only little over a 1000 characters as the two deleted columns still claim 7000 characters.

 

How these columns have been created and deleted I don’t know, but I think this is exactly what the issue is in the Vredestein database. They are probably created during the various experiments with the column size and data types.

 

Fortunately, the fix is straightforward: rebuild the table, which in the case of a table with a clustered index simply means rebuilding the index, or run a DBCC CLEANTABLE command, In other words, either run this:

 

ALTER INDEX PK__ItemType__3214EC0719576034 ON [ItemType_ExtraAreaConfigurations]

REBUILD

 

or run this:

 

DBCC CLEANTABLE (DwApolloVredestein,'ItemType_ExtraAreaConfigurations', 0)

 

As a third alternative, simply delete the single record from the settings table. Then save the Area with new settings and Dynamicweb will insert a new record without any issues ;-)

 

Votes for this answer: 1

 

You must be logged in to post in the forum