Parallelism in PostgreSQL
percona.com
percona.com
Parallelism in PostgreSQL in general:
https://speakerdeck.com/macdice/parallelism-in-postgresql-11
Deeper dives on hash joins:
https://write-skew.blogspot.com/2018/01/parallel-hash-for-po... https://speakerdeck.com/macdice/hash-joins-past-present-and-...
I will definitely read what you suggested. But keep in touch I will post more blogs for each sub-topic to cover it all.
Are we hitting memory/IO bottlenecks?
Back in the AMD Q6600 days, in my early experimentation in multi-threading I found that my MT quicksort routine hit this limit at about 50k elements. At that point further subdivision just made it go slower. The exact limit depends on how expensive the comparison operator is and the synchronization overhead for the thread pool/work queue, but there will be a limit.
Not sure if this is what's going on here, but is one aspect at least.
One theoretical solution is to have millions of parallel queries, and rather than doing random reads to satisfy them, just read the whole table sequentially.
Query latency is high, but throughout is then unconstrained.
OK, good point, I believe this is called a carousel read (spent 5 mins looking for a link, sorry no luck. I know MSSQL does a slightly fancier version of it).
I think the original article was unclear in what it was trying for, actual performance or exposition.
Edit: could have utterly sworn it was a carousel read, but no cigar. Here it is https://www.mssqltips.com/sqlservertip/4472/sql-server-enter...
A particularly nasty behavior occurs when you get into a situation where given a set of concurrent transactions, all of them must be aborted. While 2PL is not very popular these days, it does have the advantage that you can often entirely eliminate deadlock via carefully written queries. Then you just have to deal with Amdahl’s law and you won’t run into quite as catastrophic performance given high concurrency.
Andy Pavlo wrote a paper looking at this comparing different concurrency control strategies under very high levels of concurrency.
I think you mean his paper "This is the Best Paper Ever on In-Memory Multi-Version Concurrency Control" which is available here: http://www.cs.cmu.edu/~pavlo/papers/p781-wu.pdf
By the way, his courses are really excellent. I highly recommend subscribing to the CMU Database Group channel on YouTube.
The commit phase of optimistic locking is cheap except when it's a do-over, and by necessity it causes the second action to use the resource twice, the second time sequentially to the first action.
I don’t know what the blog post was trying to prove, to be honest. If I wanted to display the benefits of parallelism, i’d have at least tried to make the test heavily CPU constrained, given that that’s the entire point of being able to go parallel. I’d also have shown I/O performance and waits, along with CPU utilisation.
> .... if a parallel plan is not produced, refer to the PostgreSQL documentation on parallelism for details.
That is, there are a number of incidental features of queries that can silently disable parallelism. It becomes an art of knowing what will trip it off and another thing you have to test and think about while working with your queries.
Other than that however, it's extremely powerful to be able to use these features and I'm hopeful we'll be able to avoid a whole lot of bespoke compute services we'd otherwise need to make just to do certain compute operations in a timely manner.
Writing anything [0], locking rows (e.g., "SELECT ... FOR UPDATE"), being run in the context of a cursor or loop, invoking "PARALLEL UNSAFE" functions, and a subquery in a query that is already parallelized are all cases where it is not meaningful for the planner to try to parallelize, so it punts.
Remember, also, that this is a young implementation. The PostgreSQL community's first priority is taking great care not to eat your data. They'll find more ways to safely parallelize things.
[0] In 11+, you can get a parallel plan on, e.g., "CREATE TABLE ... AS" and "SELECT INTO", if the query is otherwise parallelizable.