News for hackers. Stuff that matters.
Re:SQLite 3.32 by iagovar on Saturday May 23, 2020 @08:43AM (#23282466)
As a non-dev intruder I have to say that I love SQLite. I do a lot of data-analysis and it makes everything easy, from fast SQL Wizardry to sharing the DB just coping a file! Just how amazing is that?!

It must sound naive to some of you, but the first time stumbled upn sqlite I was so excited!

Re:SQLite 3.32 by mmsimanga on Saturday May 23, 2020 @09:11AM (#23282639)
I work in data analysis too and SQLite is to me what MS Excel is to other people in the industry. I have development background so I never picked up in MS Excel to same degree as my colleagues from statistics backgrounds. In corporate organisations where DBAs monitor the use of their database with an eagle eye SQLite is a fantastic option to analyse several millions of lines of data on your desktop. I find DB Browser for SQLite (DB4S)[0] is invaluable when using SQLite.

[0]https://sqlitebrowser.org/

Re:SQLite 3.32 by kyllo on Saturday May 23, 2020 @11:58AM (#23283978)
If you like SQLite for data analysis, you might want to check out DuckDB https://github.com/cwida/duckdb which is billed as "SQLite for analytics."

SQLite is a row store, which is best for OLTP (point queries, inserting/updating/deleting one or a few rows at a time), while DuckDB is a column store, which means the data layout has values from the same column stored contiguously, making aggregation queries (GROUP BY) perform much better.

Re:SQLite 3.32 by erichocean on Saturday May 23, 2020 @05:08PM (#23286467)
Wow, why isn't DuckDB not more widely known!?!?! Looks incredible!!!
Re:SQLite 3.32 by kyllo on Saturday May 23, 2020 @06:36PM (#23287197)
I was wondering the same--I guess because it's fairly new (2018) and it came out of a database research group at a European university, rather than a SV tech firm. Therefore, limited marketing budget.

By the way, here's a YT video of a talk given by one of the DuckDB implementers about why they made it, what it's for, and how it works: https://www.youtube.com/watch?v=PFUZlNQIndo

Re:SQLite 3.32 by nojvek on Sunday May 24, 2020 @12:35AM (#23289114)
SQLite is started by some Aussie devs right ?
Re:SQLite 3.32 by kyllo on Sunday May 24, 2020 @01:20AM (#23289325)
SQLite was started by Dwayne Richard Hipp from North Carolina. 20 years ago.
Re:SQLite 3.32 by justinclift on Sunday May 24, 2020 @03:57AM (#23289951)
> Aussie devs

Not SQLite itself. One of the DB Browser for SQLite dev's is an Aussie though. :)

Re:SQLite 3.32 by pachico on Saturday May 23, 2020 @01:44PM (#23284864)
This is great! Thanks for sharing!
Re:SQLite 3.32 by edwinyzh on Saturday May 23, 2020 @10:06AM (#23283027)
For Windows also check HeidiSQL (open source, very feature-rich)
Re:SQLite 3.32 by mmsimanga on Saturday May 23, 2020 @10:55AM (#23283434)
Thanks for this. I used to be a longtime user of HeidiSQL but drifted away because I landed up in an Oracle environment. At the time I drifted away SQLite was not supported. I look forward to being re-acquainted with HeidiSQL.
Re:SQLite 3.32 by iagovar on Saturday May 23, 2020 @09:35AM (#23282807)
Excel is nice as a simple sandbox, and PowerQuery is amazing IMO, the problem is that it's basically impossible to work with large datasets. If you didn't know about it I recommend you to play a bit with it.

And check SQLiteStudio for Windows, is nice too.

Re:SQLite 3.32 by nojito on Saturday May 23, 2020 @10:15AM (#23283106)
I handle hundreds of millions of rows in excel trivially.

PowerPivot is extremely amazing.

Re:SQLite 3.32 by kyllo on Saturday May 23, 2020 @11:49AM (#23283893)
Most people don't realize that Excel (like PowerBI) has an in-memory, compressed, column store database inside of it.

Loading hundreds of millions of rows into it takes a while, but given a commensurate amount of RAM and a reasonable data model (single table or star schema), performing aggregations with a pivot table is pretty snappy.

Re:SQLite 3.32 by speedgoose on Saturday May 23, 2020 @11:19AM (#23283622)
PowerBI is quite nice too.
Re:SQLite 3.32 by iagovar on Saturday May 23, 2020 @01:37PM (#23284808)
Well, for me with my personal PC with a quad core and 24gb DDR3, it gets unusable for about 1 million rows, but it's true that most of my datasets have around 10 columns or so.
Re:SQLite 3.32 by nojito on Saturday May 23, 2020 @01:42PM (#23284850)
You should be using PowerPivot in Excel.

Here's a video showing rapid pivots of 100m row dataset

https://youtu.be/0WwFJ0Zg3d8?t=2285

Re:SQLite 3.32 by iagovar on Saturday May 23, 2020 @02:04PM (#23285007)
Mmm, I was using PowerQuery and then use the editor to do the transformations (don't remember exact names sorry), and I just couldn't cope with it.
Re:SQLite 3.32 by mkl on Saturday May 23, 2020 @10:43AM (#23283349)
Does SQLiteStudio let you cancel an unexpectedly slow query part way through? DB Browser for SQLite doesn't seem to, and I don't really know what I'm doing so often accidentally set off a query that can't use indices without doing "EXPLAIN QUERY PLAN" first.
Re:SQLite 3.32 by justinclift on Sunday May 24, 2020 @03:48AM (#23289894)
> DB Browser for SQLite

If it helps, our development builds for quite a few months have:

https://nightlies.sqlitebrowser.org/latest/

Our recent 3.12.0-alpha1 release does as well:

https://nightlies.sqlitebrowser.org/latest/

The first beta release for 3.12.0 should be out next week. There's not much change in it though (mostly language string changes), as the alpha1 has turned out to be really stable. :)

Re:SQLite 3.32 by googie on Saturday May 23, 2020 @06:31PM (#23287155)
It does.
Re:SQLite 3.32 by giancarlostoro on Saturday May 23, 2020 @10:00AM (#23282991)
I used to use this but if you have a JetBrains sub you can open these files directly. Or even better if its a full subscription DataGrip is fantastic and they recently added MongoDB support. Which is not perfect but good enough!
Re:SQLite 3.32 by fauigerzigerk on Saturday May 23, 2020 @11:40AM (#23283818)
I have a lot of Excel-like use cases for which SQLite would be a great fit if only it had a decimal type.
Re:SQLite 3.32 by lifepillar on Sunday May 24, 2020 @02:18AM (#23289570)
I have developed SQLiteDecimal: http://chiselapp.com/user/lifepillar/repository/sqlite3decim...

Still very rough, but usable.

Re:SQLite 3.32 by justinclift on Sunday May 24, 2020 @03:50AM (#23289911)
> WARNING: this library is NOT ready for production. Use at your own risk!

How far off do you reckon it is from being "production" ready?

Asking because we've been adding useful SQLite extensions as optional extras in our (sqlitebrowser.org) installer. Can add yours too, if you reckon the code is reasonably cross platform and shouldn't cause (many) weird issues. :)

Re:SQLite 3.32 by cordite on Saturday May 23, 2020 @11:52AM (#23283926)
As in like Java Bigdecimal, with a BigInteger on the left side, and a fixed precision on the right?
Re:SQLite 3.32 by fauigerzigerk on Saturday May 23, 2020 @12:01PM (#23284000)
As in other database systems such as Postgres. Even a C# style decimal floating point type would be sufficient.
Re:SQLite 3.32 by kyllo on Saturday May 23, 2020 @06:32PM (#23287171)
Basically--it's a struct containing a byte array, weight, scale, and sign, and all the arithmetic operations are implemented in software. So it's really slow, and each RDBMS has to implement this type from scratch, or find a vendor lib that provides a suitable one, because C/C++ standard libraries don't provide one.
Re:SQLite 3.32 by darksaints on Saturday May 23, 2020 @03:26PM (#23285648)
It does have a decimal type.
Re:SQLite 3.32 by fauigerzigerk on Saturday May 23, 2020 @05:14PM (#23286519)
No, that's just an alias for numeric type affinity which results in a binary floating point type if there's a decimal point.

There's also a long tradition of "faking" decimals with integers. I have always found that to be extremely tedious and error prone.

Re:SQLite 3.32 by time0ut on Saturday May 23, 2020 @09:38AM (#23282830)
My tools of choice are similar: sqlite, DB browser, Jupyter. I've found that DB browser struggles with analytical queries on tables over a few GB though. Still an invaluable exploratory tool.
Re:SQLite 3.32 by iagovar on Saturday May 23, 2020 @09:44AM (#23282871)
Check SQLiteStudio. DBeaver also supports SQLite as far as I remember, but it's a bit more cumbersome and really geared towards mysql etc.
Re:SQLite 3.32 by StavrosK on Saturday May 23, 2020 @12:05PM (#23284027)
> It must sound naive to some of you, but the first time stumbled upn sqlite I was so excited!

Why naive? That's the experience of all of us with SQLite.

Re:SQLite 3.32 by jventura on Saturday May 23, 2020 @09:10AM (#23282629)
Most of my web apps’ databases are an SQLite file. It’s more than enough for the ammount of traffic they serve and the db files are easy to set up and backup..
Re:SQLite 3.32 by eska on Saturday May 23, 2020 @11:48AM (#23283883)
I also always wondered why sqlite isn't used more in websites. Especially if you split heavy write workloads to a separate database file it scales quite far.
Re:SQLite 3.32 by qes on Saturday May 23, 2020 @12:30PM (#23284267)
There's no reasonable way to share a SQLite database between processes on separate machines or VMs.. What website doesn't use at least 2 instances for HA?

How do you make sure you don't lose data in a SQLite DB?

Re:SQLite 3.32 by freedomben on Saturday May 23, 2020 @02:20PM (#23285133)
I throw together plenty of simple sites intended for personal use or just a small group. I don't need nor want the added complexity of going for HA. I can easily spin up a cheap VPS with an SSD and scale amazingly far with one instance and a SQLite DB. When it's for personal use or small group it's not a problem to take it offline for maintenance/deploys. I don't even use a load balancer (tho I often throw nginx in front to do mTLS and compression). I can build a site like that in 30 minutes.

I deal with massive scale all day every day for work (kuberntes/openshift/public clouds) so I find the simplicity amazingly refreshing.

I might also say the performance of my "single box" websites is also amazingly good. I've had even developer friends ask me how I get response times so fast, and they are often surprised when I tell them.

Re:SQLite 3.32 by detaro on Saturday May 23, 2020 @01:50PM (#23284919)
Many websites just run on a single machine somewhere, with maybe some caching in front or off-loaded static files. Even HN is as far as I know still just a single box.
Re:SQLite 3.32 by samtho on Saturday May 23, 2020 @12:56PM (#23284489)
Not sure about parent’s case, but I’ve used it for small blog-type applications where the only writes are from me (the admin) creating new entries. The rest is read only and behind caches, cdns, etc. The blog is effectively a singleton. Analytics and comments are handled by 3rd party providers.
Re:SQLite 3.32 by emadda on Saturday May 23, 2020 @07:26PM (#23287558)
You can use a regional GCP disk that replicates over all zones in a region (https://cloud.google.com/compute/docs/disks#repds). You cannot mount the same disk to many VMs, but you can force mount the disk to a new VM.
Re:SQLite 3.32 by ww520 on Saturday May 23, 2020 @04:59PM (#23286382)
Just use DRDB and Linux-HA to replicate the disks hosting the master SQLite database and the standby database.
Re:SQLite 3.32 by presumably on Saturday May 23, 2020 @12:51PM (#23284433)
What’s not reasonable about TiDB?
Re:SQLite 3.32 by lenkite on Saturday May 23, 2020 @12:10PM (#23284077)
How do you architect this ? This works only for single process web-apps right ? With no HA or failover ?
Re:SQLite 3.32 by jventura on Saturday May 23, 2020 @12:28PM (#23284254)
Right! But as I said, the low traffic volume doesn’t require more than this kind of architecture.

I do regular file backups and have a cron job restarting the web apps each 20 minutes, it’s enough for now. I would love to have a more solid architecture, but it matches the traffic volume and it’s good enough..

Re:SQLite 3.32 by duskwuff on Saturday May 23, 2020 @07:12PM (#23287472)
TBH, it'll work for a lot of multi-process apps, so long as the app runs on a single server and the app doesn't do anything foolish like write to the database on every page hit. For read-mostly applications -- like a blog, wiki, or even a small web forum -- SQLite is a surprisingly adequate database.
Re:SQLite 3.32 by hobs on Saturday May 23, 2020 @09:22AM (#23282713)
I can't even tell you how many times a dev came to me with some weird question that was very simply answered by "just use sqlite."

I've never thrown more than 20GB of data at it, but it always handles things admirably, and it often (to me) makes the right calls about the level of complexity required (accepts column type defs but really just doesnt care if it maps to string.)

Re:SQLite 3.32 by darksaints on Saturday May 23, 2020 @03:28PM (#23285663)
I have done several multi-terabyte queries on it. One time I had a race with another dev to see who could get the right answer on a 3TB dataset. I was finished before his spark cluster had even spun up.
Re:SQLite 3.32 by nolok on Saturday May 23, 2020 @10:46AM (#23283375)
SQLite handles dozens of DB databases surprisingly well, especially in a single user for data analysis scenario.
Re:SQLite 3.32 by dragonshed on Saturday May 23, 2020 @09:02AM (#23282575)
I totally agree.

I'm a front-end dev that can wing backend from time to time, and I use SQLite as much as possible. On multiple projects now I've run into complications due to complexity or environments, and adding a simplified local development backend with sqlite kept down time to a minimum.

SQLite is awesome.

Re:SQLite 3.32 by ak39 on Saturday May 23, 2020 @10:57AM (#23283448)
Same. The last time I was this excited about an RDBMS in your pocket was when BerkleyDB released their Java database in a single JAR file. I am not sure when they initially released it but I remember doing some hobby projects in 2003.
Re:SQLite 3.32 by mmsimanga on Saturday May 23, 2020 @11:09AM (#23283544)
I do occasionally use Apache Derby[0] in similar manner to SQLite. Mostly when data types are critical. Works well when using DBeaver or any SQL editor that allows you to add JDBC connections.

[0]https://db.apache.org/derby/

Re:SQLite 3.32 by giancarlostoro on Saturday May 23, 2020 @09:58AM (#23282983)
At my job we started using H2 which much like SQLite has shareable databases. We now wish more databases were this simple. Its just too efficient to share a db in its total current state and someone with a little more experience or who does not have tunnel vision can probe and resolve issues. Plus you can always go between states of broken vs working.
Re:SQLite 3.32 by iagovar on Saturday May 23, 2020 @10:03AM (#23283009)
Is there any easy GUI for H2?
Re:SQLite 3.32 by sigzero on Saturday May 23, 2020 @03:45PM (#23285775)
Re:SQLite 3.32 by wener on Saturday May 23, 2020 @10:17AM (#23283120)
I use DataGrip for all database