1,487 karma · joined January 16, 2012
@danlovesproofs
We've been using WAL-E for years and this looks like a big improvement. The steady, high throughput is a big deal – our prod base backups take 36 hours to restore, so if the recovery speed improvements are as advertised, that's a big win. In the kind of situation in which we'd be using these, the difference between 9 hours and 36 hours is major.
Also, the quality of life improvements are great. Despite deploying WAL-E for years, we _still_ have problems with python, pip, dependencies, etc, so the switch to go is a welcome one. The backup_label issue has bitten us a half dozen times, and every time it's very scary for whoever is on-call. (The right thing to do is to rm a file in the database's main folder, so it's appropriately terrifying.) So switching to the new non-exclusive backups will also be great.
We're on 9.5 at the moment but will be upgrading to 10 after it comes out. Looking forward to testing this out. Awesome work!
There are a million 'db best practices' you can go implement blindly, but the point is that this methodology – determining the bottlenecking resource and then profiling to determine exactly what is consuming it – will _reliably_ yield huge wins, whereas implementing 'best practices' on gut alone is a very inefficient way to improve performance.
Another is that the parts of the country with growing economies and lots of great jobs are generally cities with incredibly high rents. It's not easy to move halfway across the country to take an entry-level job and somehow live off that if you need to pay Bay Area / NY Area / DC Area / etc rents, and doubly so if you have a family.
This is one reason I think it's so critical to build a serious urbanist movement in US. The status quo of restrictive zoning, low building, and sky-high rents keeps hundreds of thousands of people from being able to access the places that would enable them to build better lives. If we allowed our cities to grow and invested in the transit infrastructure to keep them livable at even moderately higher densities, it could unleash a tremendous amount of prosperity.
In fact, this might make the query slower. If postgres thinks it is selecting a very small number of rows, it will prefer an index scan of some kind, but a full table scan will be faster if it's retrieving 1/8th of the table (at least, for small rows like these). So, you might get a slower row retrieval and the same explosively slow join.
This is mostly fixed in 9.5: http://blog.2ndquadrant.com/jsonb-and-postgresql-9-5-with-ev...
We're in the process of switching to a more balanced schema (mentioned in this post) and the results have been pretty good so far.
Another win has been that the better stats make it possible to reliably get bitmap joins from the planner. Our configuration uses ~12 RAIDed ebs drives, so the i/o concurrency is really high and prefetching for a bitmap scan works particularly well.
Our solution has been to build a distribution layer that makes our product performant at scale, rather than sacrificing data quality. We use CitusDB for the reads and an in-house system for the writes and distributed systems operations. We have never had a problem with data corruption in PostgreSQL, aside from one or two cases early on in which we made operational mistakes.
With proper tuning and some amount of durability-via-replication, we've been able to get great results, and that's supporting ad hoc analytical reads. (For example, you can blunt a lot of the WAL headaches listed here with asynchronous commit.)
Actually this isn't true. Middle classes in the developed world are doing poorly relative to the richest in the developed world, but global poverty is on a steep decline.
Throughout the developing world, economic development is pulling hundreds of millions of people out of poverty at breakneck speed. Check out some of the data here, for starters: http://ourworldindata.org/data/growth-and-distribution-of-pr...
Interesting, and very surprising! I'm going to dig around and see if I can't figure out why this is the case.
I would have guessed there would be a minor performance improvement, because the first_value approach effectively allows PostgreSQL to discard the data sooner, instead of materializing it in an additional subquery.
I'll play with this later today and see if it performs any better. In any case, it makes the query easier to read, so we'll probably use this unless it somehow makes the function slower.
Thanks again!
The multi-column index takes up 755 mb, vs 1026 mb for the set of three single-column indexes.
Agreed in general. No one-size-fits-all answers, and schematizing your data well is going to require case-by-case attention and experimentation for the foreseeable future.
The added flexibility benefit is also nice. The ability to add a new property without migrating a schema has saved a lot of work.
Let's say you care about ten different types of "high value" events, which reference a total of six columns. I'll assume we can cover them with three multi-column indexes, although it wouldn't be hard to cook up a realistic scenario in which you'd need more. That means, for each INSERT/UPDATE, you need to write to three different indexes.
Given that the event definitions are selective, a single partial index requires a write for about 0.05% of INSERT/UPDATEs. Ten of these will cumulatively require one write on ~0.5% of inserts -- a 600x improvement over the conservative estimate above. That is, the cost of of maintaining the set of multi-column indexes should be much, much higher than the cost of maintaining the set of partial indexes.
As I mentioned in the article, the partial index approach also allows a more flexible set of predicates. What if you want to index for rows with a field that matches a fixed regex?
Edit: Apparently I can't respond to your response -- does HN have a chain length limit?
Yes -- for indexing the single event definition used for the profiling here, a multi-column index would absolutely be preferable to three single-column indexes. I didn't think to include the option because I assumed it wouldn't scale to a case in which you have ten different event types that use an overlapping but not identical set of fields. Definitely would have been a good idea to include a comment to this effect in the post.
A multi-column index on (a, b, c) can't be used for a query that filters on b and c but not a. More detailed documentation here: http://www.postgresql.org/docs/9.3/static/indexes-multicolum...
I wonder how long before postgres includes an index type optimized for in-memory workloads, e.g. a skiplist.
PostgreSQL is powerful and feature-rich, and there's still so much work to be done. (Consider that index-only scans themselves are new as of 9.2!)
Very cool project.
Measure theory is super cool.
In particular, in that sort of scenario, you might be able to mix-and-match and get a compute-optimized instance with loads of cpu power and a healthy amount of sufficiently performant storage on EBS.
It'd be interesting to dig into the history behind them. (Did pilots lobby for them, or did they make sense at some point for safety?)