Record Size Calculation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sa_wahab@yahoo.com

    #1

    Record Size Calculation

    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.

  • Bill Karwin

    #2
    Re: Record Size Calculation

    <sa_wahab@yahoo .com> wrote in message
    news:1139679866 .641954.218330@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    > 1. I want to calculate size of the record by mysql queries. Is it
    > possible..[/color]

    See http://dev.mysql.com/doc/refman/5.0/...uirements.html
    [color=blue]
    > 2. What is the best way to calculate table record size which consists
    > of Text type.[/color]

    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.


    Comment

    • Xicheng

      #3
      Re: Record Size Calculation

      sa_wahab@yahoo. com wrote:[color=blue]
      > 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.[/color]

      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

      Comment

      • sa_wahab@yahoo.com

        #4
        Re: Record Size Calculation


        Bill Karwin wrote:[color=blue]
        > <sa_wahab@yahoo .com> wrote in message
        > news:1139679866 .641954.218330@ o13g2000cwo.goo glegroups.com.. .[color=green]
        > > 1. I want to calculate size of the record by mysql queries. Is it
        > > possible..[/color]
        >
        > See http://dev.mysql.com/doc/refman/5.0/...uirements.html
        >[color=green]
        > > 2. What is the best way to calculate table record size which consists
        > > of Text type.[/color]
        >
        > 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.[/color]

        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.

        Comment

        • Jeff North

          #5
          Re: Record Size Calculation

          On 12 Feb 2006 19:02:32 -0800, in mailing.databas e.mysql
          sa_wahab@yahoo. com
          <1139799752.074 021.293100@z14g 2000cwz.googleg roups.com> wrote:
          [color=blue]
          >|
          >| Bill Karwin wrote:
          >| > <sa_wahab@yahoo .com> wrote in message
          >| > news:1139679866 .641954.218330@ o13g2000cwo.goo glegroups.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/...uirements.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.[/color]

          Yes.
          http://dev.mysql.com/doc/refman/5.0/...uirements.html
          ---------------------------------------------------------------
          jnorthau@yourpa ntsyahoo.com.au : Remove your pants to reply
          ---------------------------------------------------------------

          Comment

          • Bill Karwin

            #6
            Re: Record Size Calculation

            <sa_wahab@yahoo .com> wrote in message
            news:1139799752 .074021.293100@ z14g2000cwz.goo glegroups.com.. .[color=blue]
            > Actually my requirement is to limit the user storage like how email
            > clients doing.[/color]

            MySQL has no support for quotas to limit storage per user.
            [color=blue]
            > 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.[/color]

            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.


            Comment

            • Michael Austin

              #7
              Re: Record Size Calculation

              sa_wahab@yahoo. com wrote:
              [color=blue]
              > 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.
              >[/color]


              look at:

              http://dev.mysql.com/doc/refman/5.0/...les-table.html
              *note* version 5.0+

              select table_schema,ta ble_name,avg_ro w_length,max_ro w_length from
              information_sch ema.tables;

              --
              Michael Austin.
              DBA Consultant
              Donations welcomed. Http://www.firstdbasource.com/donations.html
              :)

              Comment

              Working...