Re:Major features of PostgreSQL 9.6 [pdf]
by dunkelheit on Monday September 26, 2016 @04:25AM
(#12580166)
> I thought a sequential scan was slow because it was limited by disk I/O
Not necessarily. Suppose you have a fairly big table that fits in the shared buffer cache and you run a query with a predicate that returns only a handful of rows. Then you would be better off scanning parts of it in parallel and then combining the results.
Re:Major features of PostgreSQL 9.6 [pdf]
by mianos on Monday September 26, 2016 @04:52AM
(#12580293)
It is worth checking out the wiki on the details of the parallel query for how and when it works: https://wiki.postgresql.org/wiki/Parallel_Query
Re:Major features of PostgreSQL 9.6 [pdf]
by amitlan on Tuesday September 27, 2016 @10:18AM
(#12589722)
or read this chapter (the wiki page's content made into the official documentation):
https://www.postgresql.org/docs/devel/static/parallel-query....
Re:Major features of PostgreSQL 9.6 [pdf]
by macdice on Monday September 26, 2016 @04:55AM
(#12580301)
Parallel sequential scan is a building block that enables other work to be done in parallel. Once you've got a way to split up a sequential scan by handing chunks to different workers, those workers can then do other CPU intensive work like filtering (involving potentially expensive expressions), partial aggregation (for example summing a subtotal that will be added to other workers' subtotals at the end) and joining (say against a hash table).
Re:Major features of PostgreSQL 9.6 [pdf]
by gaius on Monday September 26, 2016 @08:06AM
(#12581120)
Because "the disk" is the wrong abstraction here; think instead of stuffing I/O requests into a queue, letting the storage controller re-order them, then giving you a callback when the blocks are ready.
Re:Major features of PostgreSQL 9.6 [pdf]
by katnegermis on Monday September 26, 2016 @04:25AM
(#12580167)
I was wondering the exact same thing -- how can CPU-parallelism improve on a task which (to me at least) seems to be disk-IO bound?
I'm guessing that my assumption of the task being disk-IO bound is incorrect!
Re:Major features of PostgreSQL 9.6 [pdf]
by jaziek on Monday September 26, 2016 @04:50AM
(#12580281)
It's only disk IO bound if you're accessing the disk. With modern servers packing multiple TB of memory, it is likely you won't be accessing the disk at all.
Re:Major features of PostgreSQL 9.6 [pdf]
by postila on Monday September 26, 2016 @10:57PM
(#12587189)
For some cases (like single HDD and low amount of RAM) it should be so, but for some cases(from "the whole table is already loaded to RAM" to "SSD" and to "a table is partitioned among multiple drives"), it must give very good improvements for analytical queries.
This confuses me—I thought a sequential scan was slow because it was limited by disk I/O; why is it faster to hawe multiple threads waiting around for the same disk?
(I guessed maybe that it was running different sequential scans in the same query in parallel, but no, pages 3 and 4 of the PDF show parallel workers being used for a single scan of a single table)