Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Performance issue while using data type 'STRING'.

Former Member
0 Kudos

Hello All,

I have created a table for storing values of different features coming under a particular country. Since the last field 'Value field' have to hold text upto 800characters for some features, i have used the data type 'String' with character length specified as 1000. I am able to store values upto 1000characters using this. Also, the table has to hold lots and lots of value, and it will increase in future also.

Since i have mentioned the data type as 'String', I have one doubt whether this will affect the performance. Because length of most of the values in my value field is less than 75characters and in some case only it will exceed 700characters. So, my question is whether the 'String' data type will allocate the length which am specifying in the table for each entries, though the values entering is less than the specified length.

For example, if the value of my value field is 'Very High Complexity' which is of length 20characters, will the space allocation be reduced to 20 or will it be still 1000characters?

Hope someone can clarify my doubt.

Thanks In Advance,

Shino

Moved to appropriate forum

Edited by: Rob Burbank on Feb 23, 2009 4:27 PM

1 ACCEPTED SOLUTION

former_member192616
Active Contributor
0 Kudos

Hi Shino,

> i have used the data type 'String' with character length specified as 1000

how have you done that? Mabye i got something wrong, but according to the

documentation:

http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb2fd9358411d1829f0000e829fbfe/frameset.htm

Strings are by definition variable in size, while characters are fixed in size.

The string will allocate (at runtime) as much memory as needed to store the content.

The variable allocation and deallocation of memory for strings comes with a price. This price (administration overhead) is dominant for short srings ~ <= 70 byte (70 character in non-unicode systems, or 35 charaters in unicode systems). With longer strings it is not important.

Kind regards,

Hermann

10 REPLIES 10

Former Member
0 Kudos

Hi Shino

I think when you declare STRING as 1000 characters

It will be always 1000 characters length irrespective of whether your real data is 1000 or less than 1000 characters

Hope it helps

Vikas C

Former Member
0 Kudos

Hi,

One of the performance issue comes due to memory allocated.More the memory allocated more the time taken to access it.

When your create any field and allocate certain amount of memory to it.If you store value equals to its size of less to its size it memory size will be the allocated one.

So if you have create a string of 1000 size and store only 20 characters.Rest 980 is waste and degrades performance.

Hope this resolves your query.

Regards,

Gurpreet

former_member192616
Active Contributor
0 Kudos

Hi Shino,

> i have used the data type 'String' with character length specified as 1000

how have you done that? Mabye i got something wrong, but according to the

documentation:

http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb2fd9358411d1829f0000e829fbfe/frameset.htm

Strings are by definition variable in size, while characters are fixed in size.

The string will allocate (at runtime) as much memory as needed to store the content.

The variable allocation and deallocation of memory for strings comes with a price. This price (administration overhead) is dominant for short srings ~ <= 70 byte (70 character in non-unicode systems, or 35 charaters in unicode systems). With longer strings it is not important.

Kind regards,

Hermann

0 Kudos

Hi Hermann,

I just specified the data type in the domain of my 'Value field' as 'String'. Also, I've mentioned the length as 1000. But a minimum of 256characters can be specified,which is not limited. If you are entering free text with length more than 256,say 600,then the string field will automatically suit for that length. Also, if you need to enter a small text of some 50character length, this will work fine.

But the only doubt i have is whether the 'String' data type will consume much more memory than for the 'Char' or 'Lchr' data types.

Hope this will help.

Thanks and Regards,

Shino

0 Kudos

Hi Shino,

ok, you are talking about DDIC Type string. I meant ABAP built in type string in my first posting, sorry.

>So, my question is whether the 'String' data type will allocate the length which am

>specifying in the table for each entries, though the values entering is less than the specified length.

regarding space used on the database the space should be variable in size since for short strings (SSTRING) a varchar (variable characer) type is used and for long strings (STRING) LOBs (large objects) may be used they are variable as well, but they can cause aditional i/o or buffer issues. This

can be database dependent as well.

What database are you using?

Kind regards,

Hermann

0 Kudos

Hi Shino,

Well it is possible to store using STRING or LCHR in the transparent tables. There are some underlyning facts here:-

1. You can only have one such field per table

2. You cannot view them in the se11 / se16 table content browser

3. You will need to maintain an additional field for storing the length of the STRING or LCHR field.

Regarding the performance:

even though ABAP allows storing STRING or LCHR type fields in the transparent tables but as soon as the lenght of the field crosses 255 chars it is not advisable to store it directly in the transperant tables.

You should store that field in the knowledge repository and only a pointer to the knowledge repository in the transperant table field.

Anyways, Since you have only one field with such a requirement then i would suggest you use STRING instead of LCHR as in LCHR you will have to mandatorily assign a length (like 1000) so even if you are storing only 20 chars or 300 chars the system will reserve a slot of 1000 chars; this is not with string as in case of string everything would be dynamic.

The result being that the reading time increases in case of LCHR.

I Hop this answered your question.

Regards,

Sagar.

0 Kudos

Hi Shino,

>

> But the only doubt i have is whether the 'String' data type will consume much more memory than for the 'Char' or 'Lchr' data types.

One more thing is that yes STRING or LCHR will consume much more memory than CHAR since the lenght of CHAR is limited to 255 and STRING or LCHR in your case have length around 1000 chars.

But, it is ok to use string or lchr as long as you need only one such field in one table.

Best Regards,

Sagar.

0 Kudos

Hi Shino,

I tried both LCHR and STRING with your example. My suggestion is that you can go through with LCHR as your solution.

(string maintenance is not allowd in views)

Hope this solved your issue.

Thanks and Regards,

Sagar.

0 Kudos

Hello Sagar,

Thanks alot for your kind help. I tried with your suggestion and as you mentioned, LCHR is working fine, as i am unable to use string datatype in table maintenance view.

Regards,

Shino

former_member194613
Active Contributor
0 Kudos

> One more thing is that yes STRING or LCHR will consume much more memory than CHAR since the

> lenght of CHAR is limited to 255 and STRING or LCHR in your case have length around 1000 chars.

Please do not confuse actual size and reserved size of a field.

If you want to store 1000 characters of information then you need 1000 characters (compression could help but that is another story)

A character field with char1000 will however alwys need 1000 character even for the records which are nearly empty. A string will only need the required size for the actual length. At about 20 characters the string will save memory, if your data is of variable length.

Siegfried