Hacker News new | past | comments | ask | show | jobs | submit login

Would be great if there was something you could run on tables to recommend more space efficient data types based on what’s actually stored in the table.



You store numbers, all positive and up to 5k (Let's say it's all your income). So you'll get recommended ushort. Now you'll win the lottery (pun intended).

A tool could only recommend that the stored data would fit another datatype. But only business can tell you whether thats true.

I only see disadvantages or micro-optimizations.


I can’t imagine a concrete example of this


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.


Okay column type I can see, but data structure?


Depends 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: