Re: index prefetching
От | Tomas Vondra |
---|---|
Тема | Re: index prefetching |
Дата | |
Msg-id | 3cd40425-965a-5ce1-1af3-d51971c44b93@enterprisedb.com обсуждение исходный текст |
Ответ на | Re: index prefetching (Tomas Vondra <tomas.vondra@enterprisedb.com>) |
Ответы |
Re: index prefetching
|
Список | pgsql-hackers |
Hi, attached is a v4 of the patch, with a fairly major shift in the approach. Until now the patch very much relied on the AM to provide information which blocks to prefetch next (based on the current leaf index page). This seemed like a natural approach when I started working on the PoC, but over time I ran into various drawbacks: * a lot of the logic is at the AM level * can't prefetch across the index page boundary (have to wait until the next index leaf page is read by the indexscan) * doesn't work for distance searches (gist/spgist), After thinking about this, I decided to ditch this whole idea of exchanging prefetch information through an API, and make the prefetching almost entirely in the indexam code. The new patch maintains a queue of TIDs (read from index_getnext_tid), with up to effective_io_concurrency entries - calling getnext_slot() adds a TID at the queue tail, issues a prefetch for the block, and then returns TID from the queue head. Maintaining the queue is up to index_getnext_slot() - it can't be done in index_getnext_tid(), because then it'd affect IOS (and prefetching heap would mostly defeat the whole point of IOS). And we can't do that above index_getnext_slot() because that already fetched the heap page. I still think prefetching for IOS is doable (and desirable), in mostly the same way - except that we'd need to maintain the queue from some other place, as IOS doesn't do index_getnext_slot(). FWIW there's also the "index-only filters without IOS" patch [1] which switches even regular index scans to index_getnext_tid(), so maybe relying on index_getnext_slot() is a lost cause anyway. Anyway, this has the nice consequence that it makes AM code entirely oblivious of prefetching - there's no need to API, we just get TIDs as before, and the prefetching magic happens after that. Thus it also works for searches ordered by distance (gist/spgist). The patch got much smaller (about 40kB, down from 80kB), which is nice. I ran the benchmarks [2] with this v4 patch, and the results for the "point" queries are almost exactly the same as for v3. The SAOP part is still running - I'll add those results in a day or two, but I expect similar outcome as for point queries. regards [1] https://commitfest.postgresql.org/43/4352/ [2] https://github.com/tvondra/index-prefetch-tests-2/ -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Вложения
В списке pgsql-hackers по дате отправления: