views:

232

answers:

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

+1  A: 

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.

Hugues Van Landeghem
+1  A: 

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.

Marco
A: 

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.

Milan Babuškov