Inspired by your comment, I compiled a 64-bit version of Sqlite CLI. It works fine with the same query consuming "only" about 350 MB of RAM. To me it looks as if the 32bit-library of SQLite might have different limits than 64-bit library. But I can't identify such a difference on the cited page. There shouldn't be an actual OOM either as 350 MB could be managed on a 32bit platform as good as on 64bit. PS: I'm on Windows.