Firebird 中的域名
我有关于域的一般性问题。 我认识到,当我创建一个表并且不使用域时,将创建一个默认域,例如 RDB$1、RDB$2、RDB$3 等。 这是我的问题: - 默认创建的域有什么影响? - 这些会扩大我的数据库大小吗? - 这些对性能有影响吗? - 我是否应该为我使用的每种数据类型创建一个域,然后使用该域?
谢谢
I have a general questions about domains.
I recogniced, that when I create a table and I don't use a domain, a default domain will be created, such as RDB$1, RDB$2, RDB$3, aso.
Here are my questions:
- What impact has the default created domain?
- Does these enlarge my database size?
- Does these have an inpact of the performance?
- Shall I create a domain for every data type I use, and use the domain instead?
thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
影响和规模都很小。
最好使用域,因为当您更新一个域时:您会为使用它的所有字段更新它。
Impact and size are very small.
It's better to use domain because when you update one : you update it for all the fields who use it.
默认创建的域与用户创建的域具有相同的影响。
在任何情况下,创建域(用户或默认创建)的特定操作所占用的空间仅与定义域本身的系统表中存储的数据相关;
对数据库中存储的数据占用的空间没有影响。
在包含真实数据的数据库中,元数据占用的空间与数据占用的空间相比可以忽略不计,因此域的影响很小。
出于可读性和维护目的,建议使用用户域。
The default created domain has the same impact as a user created domain.
In any case the space occupied by the specific action of creating domain (user or default created) is related only to the data stored in system tables that define the domain itself;
there is no impact on the space occupied by data stored in the database.
In database containing real data the space occupied by metadata is negligible compared to space occupied by data, so the impact of domains is quite nothig.
The use of user domains is advised for readability and maintenance purpose.
对性能的唯一影响是在需要从域获取信息的管理工具中可见。假设您的数据库有 500 个表,平均有 20 列,那么就有 10000 个域。如果您使用自定义域,则可能有 50 个左右。因此,管理工具将更快地加载表和列定义。
你真正应该关心的是逻辑。拥有域可以确保您不会不匹配某些列的数据类型,例如,这可能会导致外键出现问题。此外,全局更改某些域数据类型也变得更加容易:例如,前段时间我决定更改我的一个数据库中的 Customer 表中的 CustomerID 的数据类型。它在大约 50 个外键中被引用。对于域,它就像转储 SQL 脚本和更改域的定义一样简单。如果没有域,我将不得不对一个巨大的 SQL 脚本进行搜索和替换 - 这当然很容易出错。
The only impact on performance is visible in administration tools which need to fetch info from domains. If you have a database with, let's say, 500 tables having 20 columns on average, that's 10000 domains. If you use custom domains, you might have 50 or so. So, admin tool will load table and column definitions much faster.
What you really should be concerned is logic. Having domains makes sure you don't mismatch some columns' datatypes which could create problems with foreign keys for example. Also, it makes easier to change some domain datatype globally: for example, some time ago I decided to change datatype of CustomerIDs in Customer table in one of my databases. It is referenced in about 50 foreign keys. With domains, it was as easy as dumping SQL script and changing the definition of domain. If there were no domains, I would have to do search&replace on a huge SQL script - which is of course error prone.