rbanffy 1 day ago

> compiled into query plans which do reverse table/index scans…

But are they implemented as reading files backwards? Reading datasets in any direction is very normal because all our media is, for all practical purposes, random-access. Stepping through data backwards is just a special case of random access.

1
skissane 11 hours ago

> But are they implemented as reading files backwards? Reading datasets in any direction is very normal because all our media is, for all practical purposes, random-access. Stepping through data backwards is just a special case of random access.

Well, of course they are reading the file backwards, in terms of making successive calls to pread/preadv/preadv2/aio_read/lio_listio/io_uring/etc with decreasing file offsets, or successive reads to an mmap-ed file with decreasing memory addresses.

And of course, you can't read a file backwards with fseek/fread (or lseek/read), except on a very limited number of platforms that support that – but a serious database is unlikely to be using seek+read begin with, except in unusual circumstances such as VSAM under z/OS (z/OS pread/etc only work with file descriptors, which are only supported for UNIX files, not MVS datasets)