ROW SIZE????

Hi friends,
I need to find the record size when i m fetching the data from mysql table .
example:
id|name | details|
1 |vetri | b2w |
2| peter | dog |
query:
SELECT * FROM example where id=‘1’;

When i execute this query i need to find the size(in bytes) of the resulting output.

Thanks in advance. ( ( (

I’m not quite sure what you’re asking?

Do you want to amount of RAM used to allocate the result set?

Do you want the specific data size of the columns (not including other overheads)?

For the latter:

SELECT LENGTH(name) + LENGTH(details) + 4 AS size FROM example WHERE id=1;

LENGTH() returns the byte length of the columns, the +4 is for the numberical INT type.

To calculate for more than one row:

SELECT SUM(LENGTH(name) + LENGTH(details) + 4) FROM example WHERE id=1;

I’m not quite sure what you’re asking?

Do you want to amount of RAM used to allocate the result set?

Do you want the specific data size of the columns (not including other overheads)?

For the latter:

SELECT LENGTH(name) + LENGTH(details) + 4 AS size FROM example WHERE id=1;

LENGTH() returns the byte length of the columns, the +4 is for the numberical INT type.

To calculate for more than one row:

SELECT SUM(LENGTH(name) + LENGTH(details) + 4) FROM example WHERE id=1;

Thanks for your reply. :smiley:
Is that +4 applicable for all cases.And
i need to get the exact size of the row.
so you people need to guide me whether i need to include overheads r not…
And i can see the size of entire table in myadmin
Like this
Space usage:
Type Usage
Data 2,412 B
Index 2,048 B
Total 4,460 B
but i need the size for row? help me…

Thanks in advance…

If you’re treating numberical data types as natives then INT is 4 bytes.

If you need to treat as string then again use LENGTH(id)

Native sizes per column:

INT: 4 bytes
MEDIUMINT: 3 bytes
SMALLINT: 2 bytes
TINYINT: 1 bytes

I don’t know what application you are developing so I don’t know if you need to include overheads.

You can show table information to display average row length.