ResultSet Memory

I have ResultSet of 100k records with each record has 5 cell 2 of them are of int data type and 3 are of Varchar (100) data type

my question is how the memory is allocated to resultset for these data types when a query is executed from a java program

specially to varchar data type is all the varchar(100) cells have same memory of 100 chars or it depends on the data each varchar(100) cell contains

for example say I have the following record with two cell on varchar(100)

------------------------
| "abc" | | "pqrstuv" |
------------------------

is memory size here 10 chars or 200 chars?

regards

Answer

the “varchar” type is for variable length strings. thus, your strings will only take the amount of space as the number of characters actually in the string (so 10 chars in your example). if you defined those fields as just “char” (fixed length), then they would take up 100 characters each.

Leave a Reply

Your email address will not be published. Required fields are marked *