News for hackers. Stuff that matters.
Re:Many small queries are efficient in SQLite by magicalhippo on Tuesday February 16, 2021 @04:37AM (#26152405)
We need to store weights in kg with three decimal places. If we sum to get a total, the total should be correct according to those three digits.

I'm sure we could get it to work in SQLite, but it sounds like we would have to have some layer of manual fudging that we couldn't forget about.

In our current database we just use "numeric(16, 3)" and no worries.

Re:Many small queries are efficient in SQLite by em500 on Tuesday February 16, 2021 @04:52AM (#26152482)
At the risk of sounding glib, you could store everything as integer grams?
Re:Many small queries are efficient in SQLite by magicalhippo on Tuesday February 16, 2021 @05:01AM (#26152532)
Yes of course. That's why I said I'm sure we could get it to work. But then it has to be converted to kg for actual usage. Either directly in the queries or views.

Having a fixed-point decimal type allows us to not think about once the table is created.

Same issue with money. Most of the time we need to store monetary values with two decimal places (cents).

Re:Many small queries are efficient in SQLite by dmurray on Tuesday February 16, 2021 @05:38AM (#26152702)
What kind of application are you developing where there is so little middleware between the database storage layer and the user that converting to/from kilos adds significant additional complexity, but your users aren't technical enough to just deal with having weights in grams?
Re:Many small queries are efficient in SQLite by magicalhippo on Tuesday February 16, 2021 @06:12AM (#26152871)
These are electronic versions of official forms. The user interface and reports should show what is actually being sent or has been sent.

Sure we could deal with it, but there are quite a number of tables due to different forms and messages, and then there's all the reports. Many custom ones thanks to to local officials wanting data from a certain customer in a certain way...

Re:Many small queries are efficient in SQLite by scaladev on Tuesday February 16, 2021 @06:42AM (#26153019)
Bureaucratic forms have a tendency to change unpredictably. Today they want weight in kilograms, tomorrow they'll want it in grams, and the day after that in standardized intergalactic weight units. I get what you're saying (and I don't like writing unnecessary mapping boilerplate too), but there should be a middle layer to protect the application from craziness like that.
Re:Many small queries are efficient in SQLite by magicalhippo on Tuesday February 16, 2021 @06:58AM (#26153105)
Thankfully things in our sector is fairly static in that regard, so this is seldom an issue. That sounds quite horrible indeed.

And yes, a fatter middle layer would be nice. Our next generation software will probably have more of that, this code base is over 20 years old at this point...

Re:Many small queries are efficient in SQLite by magicalhippo on Tuesday February 16, 2021 @07:00AM (#26153113)
I realize this response turned out a lot more harsh than I intended. I was in a slight rush so didn't formulate myself well, didn't mean to be abrasive.
Re:Many small queries are efficient in SQLite by mvc on Tuesday February 16, 2021 @10:03AM (#26154460)
> Most of the time we need to store monetary values with two decimal places (cents).

Yeah who cares about fractions of pennies anyway. Just makes things complicated.

Re:Many small queries are efficient in SQLite by magicalhippo on Tuesday February 16, 2021 @10:25AM (#26154705)
Yeah for being so uptight about just about everything, the officials seems quite relaxed about values slipping between the cracks due to lack of decimal places.

Like, total invoice value can only be specified with two decimal digits, typically in foreign currency. Yet we also have to specify per-line value in local currency, also with only two digits. And then the per-line values are used to calculate taxes and whatnot...

Re:Many small queries are efficient in SQLite by jrochkind1 on Tuesday February 16, 2021 @12:45PM (#26156545)
The US IRS (tax agency) allows you to round nearly all values to dollars ignoring cents altogether.
Re:Many small queries are efficient in SQLite by RedShift1 on Tuesday February 16, 2021 @04:50AM (#26152474)
You could store it in grams as an integer.