Subject | Re: [firebird-support] What are the trade-offs of CHAR vs. VARCHAR? |
---|---|
Author | Mark Rotteveel |
Post date | 2019-11-14T18:48:41Z |
On 14-11-2019 17:06, blackfalconsoftware@... [firebird-support]
wrote:
Firebird, and when the **internal implementation** in Firebird is
different. And if you do make assumption based on other database
engines, then please at least say that you do that so it is clear where
your assumptions are going wrong.
Saying with conviction that something works a certain way when it is not
is not only annoying for us who do know the internals, but potentially
confusing for people who don't know the ins and outs of Firebird.
behaviour with internal implementation details inside the Firebird
database engine.
User visible behaviour:
- CHAR: fixed width and shorter values are padded with spaces upto the
declared length
- VARCHAR: variable width (not padded)
Internal in-memory implementation:
- CHAR: fixed width and shorter values are padded with spaces up to the
declared length
- VARCHAR: 2 bytes with actual (byte) length and shorter values are
padded with NUL bytes up to the declared length
Internal storage implementation:
- for both same as in-memory, but with RLE applied to compress size
The way you reply suggests you are replying to something I said, which
is not the case.
But now that you bring it up again: a human can observe a performance
difference of a millisecond. Say the choice between CHAR or VARCHAR
could cause a millisecond difference per record (which it doesn't, but
lets assume for argument's sake), then you can observe this difference
when processing a sufficient amount of records (eg processing a 1000
records would yield a 1 second difference).
[..]
on InterBase and Firebird, and knows the internals, how you think
Firebird works. And Firebird actually doesn't work that way.
Firebird and InterBase tools, and in this respect their documentation is
wrong.
Mark
--
Mark Rotteveel
wrote:
> What do you mean I am wrong? I have merely re-iterated how all databaseTelling us how other engines work is not very relevant when discussing
> engines I have worked operate.
Firebird, and when the **internal implementation** in Firebird is
different. And if you do make assumption based on other database
engines, then please at least say that you do that so it is clear where
your assumptions are going wrong.
Saying with conviction that something works a certain way when it is not
is not only annoying for us who do know the internals, but potentially
confusing for people who don't know the ins and outs of Firebird.
> And what you are saying is that a CHAR field in Firebird acts in theNo, that was not what I said. You seem to be confusing user visible
> same manner as that of a VARCHAR field. If that were the case there
> would be no difference in how they are used and no reason to have two
> different data types.
behaviour with internal implementation details inside the Firebird
database engine.
User visible behaviour:
- CHAR: fixed width and shorter values are padded with spaces upto the
declared length
- VARCHAR: variable width (not padded)
Internal in-memory implementation:
- CHAR: fixed width and shorter values are padded with spaces up to the
declared length
- VARCHAR: 2 bytes with actual (byte) length and shorter values are
padded with NUL bytes up to the declared length
Internal storage implementation:
- for both same as in-memory, but with RLE applied to compress size
> Historically, in database development CHAR fieldsYes, and that is the user visible behaviour of those datatypes.
> were most often used for small string fields that would most often have
> a predtermined length such as a unit code whereas VARCHAR fields were
> used for data where that size at update was not generally known but
> would not exceed an expected maximum.
> Second, if you as Human, can observer the effects of processes beingYou were the first and only one to bring this up, in your reply to Ann.
> performed in milliseconds than you must have some level of magic on your
> side to be able to observe such differences.
The way you reply suggests you are replying to something I said, which
is not the case.
But now that you bring it up again: a human can observe a performance
difference of a millisecond. Say the choice between CHAR or VARCHAR
could cause a millisecond difference per record (which it doesn't, but
lets assume for argument's sake), then you can observe this difference
when processing a sufficient amount of records (eg processing a 1000
records would yield a 1 second difference).
[..]
> And I was not telling Ann anything different.Yes, which means that effectively you were mansplaining Ann, who worked
on InterBase and Firebird, and knows the internals, how you think
Firebird works. And Firebird actually doesn't work that way.
> This information is also within the links that were provided to meIBExpert.net is not a Firebird website, it is a third-party that sells
> regarding the explanation between CHAR and VARCHAR fields in the
> Firebird developer guide...
Firebird and InterBase tools, and in this respect their documentation is
wrong.
Mark
--
Mark Rotteveel