On Wed, Nov 6, 2019 at 12:00 PM Andres Freund <and...@anarazel.de> wrote: > I'd like an AM to have the *option* of implementing something better, or > at least go in the direction of making that possible.
OK. Could you see what you think of the attached patches? 0001 does some refactoring of toast_fetch_datum() and toast_fetch_datum_slice() to make them look more like each other and clean up a bunch of stuff that I thought was annoying, and 0002 then pulls out the common logic into a heap-specific function. If you like this direction, we could then push the heap-specific function below tableam, but I haven't done that yet. > It seems perfectly possible to have a helper function implementing the > current logic that you just can call with the fixed chunk size as an > additional parameter. Which'd basically mean there's no meaningful > difference in complexity compared to providing the chunk size as an > external AM property. In one case you have a callback that just calls a > helper function with one parameter, in the other you fill in a member of > the struct. I haven't tried to do this yet. I think that to make it work, the helper function would have to operate in terms of slots instead of using fastgetattr() as this logic does now. I don't know whether that would be faster (because the current code might have a little less in terms of indirect function calls) or slower (because the current code makes two calls to fastgetattr and if we used slots here we could just deform once). I suspect it might be a small enough difference not to worry too much about it either way. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
0002-Move-heap-specific-detoasting-logic-into-a-separate-.patch
Description: Binary data
0001-Code-cleanup-for-toast_fetch_datum-and-toast_fetch_d.patch
Description: Binary data