3 ms·
Yeah I figure it might be more complex for other code but I seriously only use 32bits in the database for time while we are still using mechanical storage. The
by ck2 14y ago
Yeah I figure it might be more complex for other code but I seriously only use 32bits in the database for time while we are still using mechanical storage.
The actual code for time will work fine with 64bit integers, well once it's compiled correctly in a 64bit environment which is a huge percentage of servers right now.
I'm just too old school to waste 4 bytes on millions of rows (and for index storage which does bloat) when I am not dealing with future dates.
Right now ALTER in most SQL databases is kinda slow and not done in parallel but that is certainly going to change and next-gen SSD in this decade will also change everything.
- glhaynes 14y agoIt's not the ALTER that's expensive, it's the people who have to figure out that the ALTER has to be run, set up testing environments, run test cases, verify them, run the actual update in production, etc. (Or: possibly miss it and thus end up with bad data or crashes in production.) I'd think the number of cases in which it's a worthwhile tradeoff for new development to save 4 bytes times even tens of millions of rows (each million costs you 4 MB, the size of a song) is vanishingly small today.
- ck2 14y agoIf you have to use time in multiple indexes, you would use significantly more than 4MB in a 10 million row table with 64bit vs 32bit integers.
- sethrin 14y agoSo what? You're describing a bug, not an optimization.
- Dylan16807 14y agoIf you only have 5000 products, you might as well use a 16 bit field. If you only have 10 million messages, you might as well use a 32 bit field. If you only deal with times before 2038, you might as well use a 32 bit field. It's a bug if the code isn't flexible, but there is no reason to waste extra space in the database to store 0s.
- glhaynes 14y agoJust like there was never any point in keeping the first two digits of a year? Until Y2K approached and tons of code was still in production that hadn't ever been expected to live that long. It cost companies a lot of money. Why make the same mistake again? I'm not saying optimizations like that are never worth it, but as a general rule the case would have to be made extremely well for me to ever sign off on it. And I bet in the huge majority of cases, the time cost of making that case would exceed the extra storage cost for using "unoptimized" data structures.
- mprovost 14y agoI can't find it at the moment but I remember reading a study showing that even with the cost of fixing Y2K issues it was still an economically sound decision to use two digit years given the historical cost of storage. In other words it was cheaper to fix the problem in 1999 than it would have been to buy enough mainframe storage in 1979 to store the extra two digits.
- glhaynes 14y agoHah! Yeah, I could definitely see that being true. It was hasty of me to refer to that as "a mistake": as you say, that was a world in which every byte was several orders of magnitude more expensive. To save a similar amount of money on storage today of course it'd probably have to be tens or hundreds of kilobytes wasted per record. That kind of an optimization would very often still be worth looking into and optimizing for.
- Dylan16807 14y agoWe're talking about a database here, not the code that processes a few records at a time. That code should be future proofed. But while the database design should be future proof, the exact settings don't have to be. Keep things properly isolated and nobody will ever know how many bits the database takes to store a value, and you can change it behind their backs with a single ALTER.
- 14y ago