forked from arp242/goatcounter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are a few (large-ish) database changes here: - Store all the User-Agent headers in one `user_agents` table, and the parsed browser/OS names in a `browser` and `systems` table. This is much more space-efficient: for 22 million rows it's about 1.7G of storage to store it for every pageview. This is now reduced to about 200M (~500k unique values). It also makes everything more transparent and easier to debug. - Do the same for all the pathnames: these were stored for every pageview, as well as in some stats tables together with the title. For 22 million rows there are about 1 million unique paths. This makes both the table itself as well as some indexes a lot smaller. It also allows some queries to be a bit more efficient as we can just do a int comparison instead of a string one. This also makes searching for paths much more efficient, as we no longer need to scan the large hits table, but scan the much smaller paths table instead. - Rename `id` to `table_id`; this makes joins and such much easier, and I figured I might as well do this while I'm at it. All in all, this reduces the hits table from about 6.5G + 3G index to 2.6G + 1.2G index, and the various _stats tables etc. are a bit smaller as well. This is basically how it should have been done from the start, and if I knew more about database design a year ago I would have done things different 🙃 All of this is a large change, and processing the migration may take a while if you've got a large database. It takes several hours for goatcounter.com's 22 million pageviews. It's recommended to run a "vacuum full" to free up disk space after all of this is finished (can't be run from transaction).
- Loading branch information
Showing
45 changed files
with
2,168 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.