RE: [PHP-WIN] Variable too long?
| From: | Svensson, B.A.T. | Date: | Sat, 09 Dec 2000 09:36:26 +0000 |
| Subject: | RE: [PHP-WIN] Variable too long? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4391@lists.php.net to get a copy of this message | ||
Since I never have been dealing with mySQL I don't know how
long character fields an attribute can contain in this database.
It could be a number of reasons why the string is truncated,
it could been while exporting from Access, it could be when
inserting it into the database, it could been when you return
the value from the database, it could been...
One generic way to solve this is to compose a new table with
a one-to-many relation, and in this new table insert the "story".
This table need of course at minimum three attributes
1) a foreign key to the table it is related to
2) a attribute of for example length 80 chars to keep the "story"
3) a sequence number to order the lines in the "story"
Of course this demands more programming while loading the data
into the server, but on the other hand you will be able to store
any size of story.
Assuming you are not using text pointers (binary object, etc)
to store the story, you will also save memory space in the
database since this approach will decrease the maximum number
of lost bytes to the length of the attribute.
Assume you decide you have to be able to store a story up
to 10KB with current approach - then you need to reserve this
space for ALL stories, even if they are only 1KB long...
The 10 KB hit will probably only be less than 10% of all of
your stories, and the most of them will be distributed around
5 to 7 kilo bytes of size. This mean that you in most of the
case will lose around 4KB in internal fragmentation of the
allocated memory.
But if you split thew stories in 80 bytes lines, then the
maximal lose will be 79 bytes for each story, and in average
a lose of 40 bytes will occur for each story.
Actually I am dealing with precisely this problem right now.
I have 150.000 records which carries a description filed. In
most case this description fields ranges in the length of about
30-50 characters (about 60% all data) and about 30% of the data
the description flied is less than 10 characters. Then I have
almost all the last 10% in the range of 50 - 300, except that
I have a few number of record in the range 300-400, and in even
fewer number in the range of 400-600.
What should I do? Should I allocate on attribute with the length
of 600 bytes to be able to store all the records this way? Or should
I decompose the data structure to include an extra table in the data
base?
A simply calculation shows that for each extra byte I add on into one
record I will have to add about 150KB of space to the database. Sine
most of my tuples is in the range less than 50 characters, it means that
I will lose 150KB*(600-50) ~= 80MB of internal fragmentation of disk space.
(these 150.000 rows is only loaded in the proto type system to make me
have something to play around with...)
80MB in this case might be considered "what the heck it is only 80MB",
but I know that they system will be loaded with more data in the future,
and this table might extend up to 500.000 tuples within the next 2-3 years.
Of course I can simply truncate all data after 100 bytes, and say:
"that is folk. That's what daddy got for you..." >-) Unfortunately
I am not able to do that in this case since it is scientific data
I am dealing with (financial data you can always truncated and then
claim: "it is a rounding error...", or "it is to technical complicated
to explain why we can't do this...", or "this budget wont allow us to
incorporate all the data..." ;)
Regards,
Anders
>-----Original Message-----
>From: Asendorf, John [mailto:JAsendorf@lcounty.com]
>Sent: Thursday, December 07, 2000 10:15 PM
>To: Php-Windows (E-mail)
>Subject: [PHP-WIN] Variable too long?
>
>
>I'm putting some date into and then pulling it out of M$
>Access. It's a news and events database. The field $story
>has the potential to be very long. Here's my problem.
>
>When entering the story through a web form, the entire story enters
>regardless of length. ( > 6000 characters tested works so far)
>The Access memo field is holding the data beautifully. The
>problem comes when I try to get the data back out of the database.
>Somewhere around the 4200 character, it poops out. Any suggestions?
>
>Thanks in advance,
>
>John
>
>---------------------
>Founder of
>The 'What Kind of Idiot Uses PHP with IIS with Oracle on NT?'
>Consortium
>
>Members: John Asendorf, Thomas Kryger, Florian Clever, Ron Woods, Bod
>
>John Asendorf - jasendorf@lcounty.com
>Web Applications Developer
>http://www.lcounty.com - NEW FEATURES ADDED DAILY!
>Licking County, Ohio, USA
>740-349-3631
>
>Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur.
>
>
>
>
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
>For additional commands, e-mail: php-windows-help@lists.php.net
>To contact the list administrators, e-mail:
>php-list-admin@lists.php.net
>