On Fri, Jan 16, 2015 at 11:49 PM, Robert Haas <robertmh...@gmail.com> wrote: > > As mentioned downthread, a far bigger consideration is the I/O pattern > we create. A sequential scan is so-called because it reads the > relation sequentially. If we destroy that property, we will be more > than slightly sad. It might be OK to do sequential scans of, say, > each 1GB segment separately, but I'm pretty sure it would be a real > bad idea to read 8kB at a time at blocks 0, 64, 128, 1, 65, 129, ... > > What I'm thinking about is that we might have something like this: > > struct this_lives_in_dynamic_shared_memory > { > BlockNumber last_block; > Size prefetch_distance; > Size prefetch_increment; > slock_t mutex; > BlockNumber next_prefetch_block; > BlockNumber next_scan_block; > }; > > Each worker takes the mutex and checks whether next_prefetch_block - > next_scan_block < prefetch_distance and also whether > next_prefetch_block < last_block. If both are true, it prefetches > some number of additional blocks, as specified by prefetch_increment. > Otherwise, it increments next_scan_block and scans the block > corresponding to the old value. >
Assuming we will increment next_prefetch_block only after prefetching blocks (equivalent to prefetch_increment), won't 2 workers can simultaneously see the same value for next_prefetch_block and try to perform prefetch for same blocks? What will be value of prefetch_increment? Will it be equal to prefetch_distance or prefetch_distance/2 or prefetch_distance/4 or .. or will it be totally unrelated to prefetch_distance? With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com