找出一行在数据库中占用了多少存储空间
有没有办法找出数据库中的一行占用了多少空间(在磁盘上)?
我很想在 SQL Server CE 上看到它,但 SQL Server 2008 却无法正常工作(我在两者中存储了大约相同的数据)。
我问的原因是我的 SQL Server CE 数据库中有一个 Image 列(它是 SQL 2008 数据库中的 varbinary[max]),并且我现在需要知道在最大化内存之前我可以存储多少行设备。
Is there a way to find out how much space (on disk) a row in my database takes up?
I would love to see it for SQL Server CE, but failing that SQL Server 2008 works (I am storing about the same data in both).
The reason I ask is that I have a Image column in my SQL Server CE db (it is a varbinary[max] in the SQL 2008 db) and I need to know now many rows I can store before I max out the memory on my device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许不是您想要的 100%,但如果您想知道图像需要多大尺寸,只需执行
您需要自己执行的任何其他附加计数(如预测等)。
Maybe not the 100% what you wanted but if you want to know how much size an Image take just do
Any other additional counting you need to do yourself (as in prediction etc).
varbinary(max) 列本身每行可能包含最多 2GB 的数据。对于基于现有数据的估计使用情况,也许您可以使用 DATALENGTH 函数进行一些分析,以计算出典型图像占用的空间,并从那里进行推断。
A varbinary(max) column could potentially contain up to 2GB of data by itself for each row. For estimated use based on existing data, perhaps you could do some analysis using the DATALENGTH function to work out what space a typical one of your images is taking up, and extrapolate from there.
您只能做出粗略的猜测 - 对于“在耗尽设备内存之前我可以存储多少行”这个问题没有确切的答案,因为您不知道独占使用您的设备 - 其他程序也会占用资源,并且您只能知道当前有多少可用存储空间,而无法知道将来的某个时间。此外,您的图像可能被压缩,因此占用不同数量的 RAM。
出于猜测目的,图像的大小就可以很好地近似行大小;行结构的开销可以忽略不计。
You can only make rough guesses - there is no exact answer to the question "how many rows I can store before I max out the memory on my device" since you do not have exclusive use of your device - other programs take resources too, and you can only know how much storage is available at the present time, not at some time in the future. Additionally, your images are likely compressed and therefore take variable amounts of RAM.
For guessing purposes, simply the size of your image is a good approximation of the row size; the overhead of the row structure is negligible.