| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Peter Geoghegan <pg(at)bowt(dot)ie> |
| Cc: | Tomas Vondra <tomas(at)vondra(dot)me>, Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Georgios <gkokolatos(at)protonmail(dot)com>, Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
| Subject: | Re: index prefetching |
| Date: | 2026-04-04 05:33:32 |
| Message-ID: | e6avgxqkonquofdstnvt5zq72x6zmolz5vojshk2b3ptsksdmw@2mf4bmp4pank |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On 2026-04-04 01:21:53 -0400, Andres Freund wrote:
> > +StaticAssertDecl(INDEX_SCAN_MAX_BATCHES <= PG_UINT8_MAX + 1,
> > + "INDEX_SCAN_MAX_BATCHES must fit in uint8 ring buffer indexes");
>
> I'd just use a < without the + 1 on the other side :)
Actually, I think there are actual issues around this. Once you set
INDEX_SCAN_MAX_BATCHES to 256, there are a lot of, justified looking,
warnings.
[1/1 1 100%] Compiling C object src/backend/postgres_lib.a.p/access_heap_heapam_handler.c.o
In file included from ../../../../../home/andres/src/postgresql/src/include/access/heapam.h:19,
from ../../../../../home/andres/src/postgresql/src/backend/access/heap/heapam_handler.c:23:
../../../../../home/andres/src/postgresql/src/include/access/relscan.h: In function 'index_scan_batch_full':
../../../../../home/andres/src/postgresql/src/include/access/relscan.h:488:45: warning: comparison is always false due to limited range of data type [-Wtype-limits]
488 | return index_scan_batch_count(scan) == INDEX_SCAN_MAX_BATCHES;
| ^~
I'm also not sure this is actually quite right
/*
* Do we already have a batch loaded at 'idx' offset in scan's ring buffer?
*
* NOTE: a stale batch idx can alias a currently-loaded range after uint8
* overflow, producing a false positive. False negatives are not possible.
*/
static inline bool
index_scan_batch_loaded(IndexScanDescData *scan, uint8 idx)
{
return (int8) (idx - scan->batchringbuf.headBatch) >= 0 &&
(int8) (idx - scan->batchringbuf.nextBatch) < 0;
}
once the differences between the values don't fit into an int8 anymore. But
I'm tired.
Greetings,
Andres Freund
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hayato Kuroda (Fujitsu) | 2026-04-04 06:20:35 | RE: Adding REPACK [concurrently] |
| Previous Message | Andres Freund | 2026-04-04 05:21:53 | Re: index prefetching |