Record Size Calculation
am 11.02.2006 18:44:26 von sa_wahab
Hi,
1. I want to calculate size of the record by mysql queries. Is it
possible..
2. What is the best way to calculate table record size which consists
of Text type.
Regards,
@wahab.
Re: Record Size Calculation
am 12.02.2006 02:15:15 von Bill Karwin
wrote in message
news:1139679866.641954.218330@o13g2000cwo.googlegroups.com.. .
> 1. I want to calculate size of the record by mysql queries. Is it
> possible..
See http://dev.mysql.com/doc/refman/5.0/en/storage-requirements. html
> 2. What is the best way to calculate table record size which consists
> of Text type.
TEXT types, like other BLOB types and VARCHAR, use a variable amount of
storage per record, based on the content stored there. So it's hard to
predict the amount of storage accurately. You have to fetch each record and
see what's stored there.
Regards,
Bill K.
Re: Record Size Calculation
am 13.02.2006 03:37:43 von xicheng
sa_wahab@yahoo.com wrote:
> Hi,
>
> 1. I want to calculate size of the record by mysql queries. Is it
> possible..
> 2. What is the best way to calculate table record size which consists
> of Text type.
>
> Regards,
> @wahab.
you may do it outside mysql, for example(under WinXP):
mysql -e "select field1, field2, field3 from mytable" mydb -p > a.txt
and then handle the file which contains tab separated records:
perl -lne " tr/\t//; $t += length }{ print$t" a.txt
this command trims tab and newlines, and then adds up the number of
characters in each line. $t finally prints the total number of
characters you have in your query result.
Best,
Xicheng
Re: Record Size Calculation
am 13.02.2006 04:02:32 von sa_wahab
Bill Karwin wrote:
> wrote in message
> news:1139679866.641954.218330@o13g2000cwo.googlegroups.com.. .
> > 1. I want to calculate size of the record by mysql queries. Is it
> > possible..
>
> See http://dev.mysql.com/doc/refman/5.0/en/storage-requirements. html
>
> > 2. What is the best way to calculate table record size which consists
> > of Text type.
>
> TEXT types, like other BLOB types and VARCHAR, use a variable amount of
> storage per record, based on the content stored there. So it's hard to
> predict the amount of storage accurately. You have to fetch each record and
> see what's stored there.
>
> Regards,
> Bill K.
Thx for ur reply Mr.Bill.
Actually my requirement is to limit the user storage like how email
clients doing. If i do caculation on everytime when the page display,
that would be slower the server performance. Instead, is it nice if
calculate the amount of storage then store in the same record in a
clolumn while insert or update, and while fetching just SUM the storage
column. Or is there any other way!!!
And let say.. if i have value 12 in INT type column, and I have value
12345 in other INT type column.. does both occupy 4 bytes each.
Regards,
@wahab.
Re: Record Size Calculation
am 13.02.2006 09:02:29 von Jeff North
On 12 Feb 2006 19:02:32 -0800, in mailing.database.mysql
sa_wahab@yahoo.com
<1139799752.074021.293100@z14g2000cwz.googlegroups.com> wrote:
>|
>| Bill Karwin wrote:
>| > wrote in message
>| > news:1139679866.641954.218330@o13g2000cwo.googlegroups.com.. .
>| > > 1. I want to calculate size of the record by mysql queries. Is it
>| > > possible..
>| >
>| > See http://dev.mysql.com/doc/refman/5.0/en/storage-requirements. html
>| >
>| > > 2. What is the best way to calculate table record size which consists
>| > > of Text type.
>| >
>| > TEXT types, like other BLOB types and VARCHAR, use a variable amount of
>| > storage per record, based on the content stored there. So it's hard to
>| > predict the amount of storage accurately. You have to fetch each record and
>| > see what's stored there.
>| >
>| > Regards,
>| > Bill K.
>|
>| Thx for ur reply Mr.Bill.
>|
>| Actually my requirement is to limit the user storage like how email
>| clients doing. If i do caculation on everytime when the page display,
>| that would be slower the server performance. Instead, is it nice if
>| calculate the amount of storage then store in the same record in a
>| clolumn while insert or update, and while fetching just SUM the storage
>| column. Or is there any other way!!!
>|
>| And let say.. if i have value 12 in INT type column, and I have value
>| 12345 in other INT type column.. does both occupy 4 bytes each.
Yes.
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements. html
------------------------------------------------------------ ---
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
------------------------------------------------------------ ---
Re: Record Size Calculation
am 13.02.2006 19:15:57 von Bill Karwin
wrote in message
news:1139799752.074021.293100@z14g2000cwz.googlegroups.com.. .
> Actually my requirement is to limit the user storage like how email
> clients doing.
MySQL has no support for quotas to limit storage per user.
> And let say.. if i have value 12 in INT type column, and I have value
> 12345 in other INT type column.. does both occupy 4 bytes each.
That's correct. The storage required by a given numeric data type is not
affected by the value you store there. You can't get space back by storing
negative values! :-)
Regards,
Bill K.
Re: Record Size Calculation
am 22.02.2006 16:30:03 von Michael Austin
sa_wahab@yahoo.com wrote:
> Hi,
>
> 1. I want to calculate size of the record by mysql queries. Is it
> possible..
> 2. What is the best way to calculate table record size which consists
> of Text type.
>
> Regards,
> @wahab.
>
look at:
http://dev.mysql.com/doc/refman/5.0/en/tables-table.html
*note* version 5.0+
select table_schema,table_name,avg_row_length,max_row_length from
information_schema.tables;
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)