List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:December 28 2002 3:06pm
Subject:Re: Mysql Query request
View as plain text  
At 2:40 -0800 12/28/02, Arun Kumar wrote:
>But if I have varchar fields won't the size of the
>record vary based on the actual contents in the
>varchar fields.

Of course.  My answer remains the same.  Perhaps I should
add that what all this means is that you must perform
the calculations on a per-record basis, and that these
calculations, though not especially difficult, are likely
to become fairly ugly as the number of columns in your table

Don't forget that a VARCHAR containing a 10-byte
string takes a different amount of storage than, say,
a MEDIUMTEXT, TEXT, or LONGTEXT containing a 10-byte

If what you really want to do (though this is *not*
what you said) is to order by the length of a given
string column, just do:

SELECT .... , LENGTH(col_name) FROM tbl_name ... ORDER BY LENGTH(col_name);

Add the appropriate constant to the LENGTH() expression to factor
in the extra number of bytes required internally to store the column
length.  (E.g., 1 for VARCHAR, 4 for LONGTEXT.)

>--- Paul DuBois <paul@stripped> wrote:
>>  At 18:38 -0800 12/27/02, Arun Kumar wrote:
>>  >Dear All,
>>  >  I have a table 'X', I want to display the record
>>  >  in this table 'X' which has occupied the maximum
>>  >  number of bytes, i.e i want a query/queries to
>>  >display the record with maximum size. I would also
>>  >like to print the
>>  >  record size as well.
>>  >
>>  >  Any help in this front would be great.
>>  >  Arun
>>  You'll have to calculate record size yourself based
>>  on knowledge
>>  about the types of the columns in the table and the
>>  storage occupied
>  > by those types.

Mysql Query requestArun Kumar28 Dec
  • Re: Mysql Query requestPaul DuBois28 Dec
    • Re: Mysql Query requestArun Kumar28 Dec
      • re: Re: Mysql Query requestEgor Egorov28 Dec
      • Re: Mysql Query requestPaul DuBois28 Dec