3 ms·
Examples are easy, usefulness... harder to imagine. Simple example, bigint column where all values would fit in smallint or if only 0/1 are present then boolea
by jpgvm 3y ago
Examples are easy, usefulness... harder to imagine.
Simple example, bigint column where all values would fit in smallint or if only 0/1 are present then boolean.
For a more complex idea if a large number of boolean columns are present in a table suggest packing them into integer/bigint as appropriate or bit(n) if individual querying/indexing via bit operators is needed.
There are many ways to claw back bytes on disk from PostgreSQL if you really need to and a lot of them could be suggested automatically.
The reason I say usefulness is harder to imagine is I don't know of anyone that would want to do this but wouldn't know how or where to look for these strategies. It's as if awareness of the need is commensurate with ability to resolve it.
- klysm 3y agoOkay column type I can see, but data structure?
- jpgvm 3y agoDepends what you mean by data structure. If you mean across multiple tables the most obvious answer is a tool that helps improve normalisation. Otherwise I'm not really sure what else you can mean by data structure that isn't how the data is stored on disk or how it's arranged into relations.