Question Details

No question body available.

Tags

database server protocol endianness

Answers (2)

Accepted Answer Available
Accepted Answer
August 28, 2025 Score: 7 Rep: 3,105 Quality: Expert Completeness: 30%

However, this seems inefficient.

...

Modern CPUs have efficient byte-swap instructions

Make up your mind, my friend.

It is not inefficient. And in fact the overhead of this conversion disappears in the crowd of all the other things that a database server and client has to do (sophisticated i/o, indexing, caching, query planning, etc).

We are talking about wire format (de)serialization only. This is typically the least expensive part of query execution.

A seemingly better approach would be:

Define "better". Your suggestion increases complexity of the protocol. In exchange for a potential performance boost, likely not observable at all. And complexity means bugs. And it means potential security issues. For nothing.

Cpu calculations are the least important thing when it comes to database efficiency (and in fact most systems efficiency). And often it is better to exchange it for simplicity.

August 30, 2025 Score: 1 Rep: 49,610 Quality: Low Completeness: 10%

There are clients, which may be big or littleendian, and servers which may be big or littleendian. Clients have to convert data to or from the byte order that the server expects.

So with native byte ordering, the client needs to find out the byte ordering of the server, then needs to convert the data in one of two ways. With fixed byte order on the server, the client doesn’t need the servers byte ordering, and doesnt need two code paths for the conversion.