News for hackers. Stuff that matters.
Re:SQLite Release 3.37.0 by the_duke on Sunday November 28, 2021 @03:38AM (#29367247)
You really don't want to store timestamps as text.

It's horrible for performance. A iso8601 timestamp takes at least double the amount of bytes (without a timezone), but more importantly you need to parse and validate the timestamp each time you use it. Filtering and sorting suffer a lot. Iso8601 without timezones can in theory be sorted trivially without parsing, but sorting strings is still a lot more expensive than sorting arrays of int64. And you also have to make sure to never write a different timezone. Why not just use an int?

You then have to parse the string into the native datetime type again in application code.

You also need to add a custom check constraint to prevent writing garbage to the column, which is easy to forget.

Re:SQLite Release 3.37.0 by littlecranky67 on Sunday November 28, 2021 @05:15AM (#29367731)
SQLite is not postgres. Often sqlite dbs span only a couple of MB, ie when used in an App, and performance might not be as important as readability during debugging/development.
Re:SQLite Release 3.37.0 by hnarn on Sunday November 28, 2021 @06:07AM (#29367971)
The argument "this doesn't matter because all SQLite databases are small anyway" does not hold water. There are many large SQLite databases out there. And even if there wasn't, storing timestamps as text is simply and fundamentally A Bad Idea(tm).
Re:SQLite Release 3.37.0 by littlecranky67 on Tuesday November 30, 2021 @04:10AM (#29390327)
True, but I think SQLite has a design goal of being an embedded DB.

As for your argument to store timestamps as text, look at DynamoDB who only allows storing dates as text, and it is designed to handle petabytes of data.