ResultSet内存 [英] ResultSet Memory

查看:171
本文介绍了ResultSet内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有100k记录的ResultSet,每个记录有5个单元格,其中2个是int数据类型,3个是Varchar(100)数据类型

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

我的问题是从java程序执行查询时如何为这些数据类型的结果集分配内存

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

特别是varchar数据类型是所有varchar(100)单元格都有相同的100个字符的内存或它取决于每个varchar(100)单元格包含的数据

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

例如说我有以下记录,其中两个单元格在varchar(100)

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


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

内存大小是10个字符还是200个字符?

is memory size here 10 chars or 200 chars?

问候

推荐答案

varchar类型用于可变长度字符串。因此,你的字符串只会占用字符串中实际字符数的空间量(在你的例子中为10个字符)。如果你将这些字段定义为char(固定长度),那么然后它们将占用100个字符。

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.

这篇关于ResultSet内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆