SQL Server 数据格式

发布于 2024-12-14 01:03:57 字数 402 浏览 3 评论 0原文

我正在为我的应用程序编写一个高性能数据检索/存储类,它使用 SqlDataReader 从 SQL 服务器检索数据。

出于好奇,我想知道来自 SQL Server 的数据是什么形式。人物?二进制?还有其他形式吗?

不幸的是,我无法在办公室进行任何数据包嗅探,这是我认为可以找到答案的一种方式。

编辑:这个问题的目的是确定从 SQL Server 检索数据的格式,以便在将数据放入数据结构之前允许尽可能少的操作。

这个问题与我之前的一个问题有关,我发现转换之间的区别将数据格式转换为字符串会对性能产生重大影响。

I am working on writing a high-performance data retrieval/storage class for my application that uses a SqlDataReader to retrieve data from a SQL server.

Out of curiosity, I wanted to know what form the data comes in from the SQL server. Characters? Binary? Some other form?

Unfortunately I cannot do any packet sniffing at my office, which is one way I think this answer could be found.

EDIT: The purpose of this question was to determine the format the data is retrieved in from SQL server to allow for as little manipulation as possible before placing it in a data structure.

This question is in relation to a previous question of mine where I found the difference between converting data formats into strings produces a significant impact on performance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉月流沐 2024-12-21 01:03:57

该格式记录在表格数据流协议规范< /a>.话虽这么说,协议和线路格式在很大程度上是无关紧要的,如果您检索如此多的数据而对传输速度很重要,那么您已经走上了错误的道路。

确保您的数据访问得到优化,最重要的是您的数据模型设计良好并且符合预期的工作负载(换句话说:为关键查询提供覆盖索引)。

如果您检索大块数据(例如存储在数据库中的媒体文件),则有一些特定的方法可以使用 SqlCommand 类,即 SequentialAccess 行为标志:

为 DataReader 提供一种处理包含列的行的方法
具有较大的二进制值。而不是加载整行,
SequentialAccess 使 DataReader 能够以流的形式加载数据。你
然后可以使用 GetBytes 或 GetChars 方法来指定一个字节
开始读操作​​的位置,以及有限的缓冲区大小
返回的数据。

有关如何使用此功能的示例,请参阅 通过 ASP.Net MVC 从 SQL Server 下载和上传图像

The format is documented at Tabular Data Stream Protocol Specification. That being said, the protocol and wire format are largely irrelevant, if you retrieve so much data as to for the speed of transfer to matter you are already deep down the wrong path.

Make sure your data access is optimized, and most importantly your data model is well designed and matches the workload expected (in other words: have covering indexes for the critical queries).

If you retrieve large chunks of data (eg. media files stored in the database) then there are some specific ways to use the SqlCommand class, namely the SequentialAccess behavior flag:

Provides a way for the DataReader to handle rows that contain columns
with large binary values. Rather than loading the entire row,
SequentialAccess enables the DataReader to load data as a stream. You
can then use the GetBytes or GetChars method to specify a byte
location to start the read operation, and a limited buffer size for
the data being returned.

For an example of how to use this, see Download and Upload images from SQL Server via ASP.Net MVC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文