Live data from Hacker News

Hosting SQLite databases on GitHub Pages or any static file hoster

phiresky.github.io

111–120 of 252 posts

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#111
post #44

Earlier quoted context omitted.

I'm curious, in what manner could this method speed up Next.js builds? That's all done locally, which negates the effect of HTTP range requests, right?

I'm guessing they mean rather than build a static Next site that generates 10k+ pages (or whatever large means in the given context), it instead creates one page that just queries the data from the client. I have one Next static site that has about 20k pages and takes about 20 minutes to build and deploy. I think that's an acceptable build time. But I do know of other people around the net who have mentioned having s…

Generating 20k pages in 20mins is impressive, 16 pages a second on average.

In my experience, it can take a couple of minutes just to deploy 20 pages, but that could just be the overhead of Typescript and SASS compilation too...

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#112
post #74

The question I had is answered by this line of code: xhr.setRequestHeader("Range", "bytes=" + from + "-" + to); I am a little surprised you can just do that. In https://github.com/phiresky/sql.js-httpvfs/blob/master/src/l...

Not all webservers support/enable it, so YMMV. But as long as you're dealing with a known server that does, then gravy!

nginx enables it by default. Another ingenious use of range request is zsync, it allows you to diff compressed binaries on a remote with local ones, so that you only have to download what has changed on an update. AppImage uses this

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#113
post #43
post #41

Pop open the network pane in the browser tools and try running this SQL query for a demo of how clever this is: select country_code, long_name from wdi_country order by rowid desc limit 100 It fetches just 54.2KB of new data (across 49 small HTTP requests) to return 100 results - from a statically hosted database file that's 668.8MB! I have an animated GIF demo of this here: https://twitter.com/simonw/status/13889338…

So assuming no country has a name longer than 98 characters and that all country codes are 2 characters, that is over 500% overhead? Are you missing a /s in your post?

This might be true.

But this approach lets you actually work out what the optimal size is:

  select sum(length(country_code) + length(long_name)) from wdi_country;
gives: 6307

Or on average:

  select sum(length(country_code) + length(long_name))/count(*) from wdi_country;
gives: 23

(Note that it doesn't seem possible to use aggregation functions with a limit clause)

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#114
post #74

The question I had is answered by this line of code: xhr.setRequestHeader("Range", "bytes=" + from + "-" + to); I am a little surprised you can just do that. In https://github.com/phiresky/sql.js-httpvfs/blob/master/src/l...

One of the heaviest users of range requests is (or was) the Adobe Acrobat PDF plugin.

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#115
post #31

Amazing, especially - for me - that the FTS5 full-text search just works. Longer term, I am if it were possible to split the DB code into read and write parts and cross-compile only read part for delivery to the browser.

If you are interested in full-text search on the client, Lunr is also an option: https://lunrjs.com/docs/index.html

Time to create the index for lunr limits the size of the data-set that can be used. If you have a lot of tiny documents, then it is more practical to scan the documents directly, rather than using the lunr index.

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#116
post #101

Earlier quoted context omitted.

Where has it been suggested that this is the best solution for "the average SQLite user", instead of a tool you can use if it fits your requirements? To take your 10MB number, the article starts by mentioning you can probably just download the entire thing if you aren't above that exact same number.

I made two claims: > this would be unusable over high latency links. That is objectively true > SQLite databases of pure data usually aren’t over 10MB in size. No one here has refuted this point. Any other counterargument is addressing a claim I did not make.

It's not anymore unusable over high latency links than most website. Also worth noting that the caching is very smart, so once things are downloaded it's very fast.

But most high latency links are very slow (so downloading large databases is a horrible experience) and (more importantly) are often priced by the size of downloads.

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#117
post #111
post #44

Earlier quoted context omitted.

I'm guessing they mean rather than build a static Next site that generates 10k+ pages (or whatever large means in the given context), it instead creates one page that just queries the data from the client. I have one Next static site that has about 20k pages and takes about 20 minutes to build and deploy. I think that's an acceptable build time. But I do know of other people around the net who have mentioned having s…

Generating 20k pages in 20mins is impressive, 16 pages a second on average. In my experience, it can take a couple of minutes just to deploy 20 pages, but that could just be the overhead of Typescript and SASS compilation too...

Hugo claims <1ms a page. Which would mean 20k pages in under 20 seconds. 20k pages in 20 mins is not fast!

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#118
post #100

Earlier quoted context omitted.

Have you actually read the article? SQLite is unmodified, and thinks it runs on a virtual file system, which fetches file chunks via HTTP range headers. It's REALLY impressive that you only need to read 54 KB out of 700 MB, to fetch the records.

It's impressive on one hand. On the other it's still a lot of overhead.

For a casual or personal use case though, the alternative of running a client-server database on something like a VPS is probably more overhead than this. It's unlikely to be a very scalable option, but for use cases as described by the author it seems like a good fit.

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#119
post #116

Earlier quoted context omitted.

I made two claims: > this would be unusable over high latency links. That is objectively true > SQLite databases of pure data usually aren’t over 10MB in size. No one here has refuted this point. Any other counterargument is addressing a claim I did not make.

It's not anymore unusable over high latency links than most website. Also worth noting that the caching is very smart, so once things are downloaded it's very fast. But most high latency links are very slow (so downloading large databases is a horrible experience) and (more importantly) are often priced by the size of downloads.

> It's not anymore unusable over high latency links than most website.

That’s false. Not all web applications suffer equally from high latency links. Depends on how reliant the web application is on independent requests. Making one request and receiving a single bulk download is much less bad than making many dependent requests on a high latency link.

Re: Hosting SQLite databases on GitHub Pages or any static file hoster

#120
post #111
post #44

Earlier quoted context omitted.

I'm guessing they mean rather than build a static Next site that generates 10k+ pages (or whatever large means in the given context), it instead creates one page that just queries the data from the client. I have one Next static site that has about 20k pages and takes about 20 minutes to build and deploy. I think that's an acceptable build time. But I do know of other people around the net who have mentioned having s…

Generating 20k pages in 20mins is impressive, 16 pages a second on average. In my experience, it can take a couple of minutes just to deploy 20 pages, but that could just be the overhead of Typescript and SASS compilation too...

Oops, my memory was off. It's 10,925 pages and the last build took 18 minutes.
Post reply on HN