Re: Pluggable Storage - Andres's take
Andres Freund <andres@anarazel.de>
Hi, On 2018-07-05 15:25:25 +0300, Alexander Korotkov wrote: > > - I think the move of the indexing from outside the table layer into the > > storage layer isn't a good idea. It lead to having to pass EState into > > the tableam, a callback API to perform index updates, etc. This seems > > to have at least partially been triggered by the speculative insertion > > codepaths. I've reverted this part of the changes. The speculative > > insertion / confirm codepaths are now exposed to tableam.h - I think > > that's the right thing because we'll likely want to have that > > functionality across more than a single tuple in the future. > > I agree that passing EState into tableam doesn't look good. But I > believe that tableam needs way more control over indexes than it has > in your version patch. If even tableam-independent insertion into > indexes on tuple insert is more or less ok, but on update we need > something smarter rather than just insert index tuples depending > "update_indexes" flag. Tableam specific update method may decide to > update only some of indexes. For example, when zheap performs update > in-place then it inserts to only indexes, whose fields were updated. > And I think any undo-log based storage would have similar behavior. > Moreover, it might be required to do something with existing index > tuples (for instance, as I know, zheap sets "deleted" flag to index > tuples related to previous values of updated fields). I agree that we probably need more - I'm just inclined to think that we need a more concrete target to work against. Currently zheap's indexing logic still is fairly naive, I don't think we'll get the interface right without having worked further on the zheap side of things. > > - The visibility functions relied on the *caller* performing buffer > > locking. That's not a great idea, because generic code shouldn't know > > about the locking scheme a particular AM needs. I've changed the > > external visibility functions to instead take a slot, and perform the > > necessary locking inside. > > Makes sense for me. But would it cause extra locking/unlocking and in > turn performance impact? I don't think so - nearly all the performance relevant cases do all the visibility logic inside the AM. Where the underlying functions can be used, that do not do the locking. Pretty all the converted places just had manual LockBuffer calls. > > - HOT was encoded in the API in a bunch of places. That doesn't look > > right to me. I tried to improve a bit on that, but I'm not yet quite > > sure I like it. Needs written explanation & arguments... > > Yes, HOT is heapam specific feature. Other tableams might not have > HOT. But it appears that we still expose hot_search_buffer() function > in tableam API. But that function have no usage, so it's just > redundant and can be removed. Yea, that was a leftover. > > - the heap tableam did a heap_copytuple() nearly everywhere. Leading to > > a higher memory usage, because the resulting tuples weren't freed or > > anything. There might be a reason for doing such a change - we've > > certainly discussed that before - but I'm *vehemently* against doing > > that at the same time we introduce pluggable storage. Analyzing the > > performance effects will be hard enough without changes like this. > > I think once we switched to slots, doing heap_copytuple() do > frequently is not required anymore. It's mostly gone now. > > - I've for now backed out the heap rewrite changes, partially. Mostly > > because I didn't like the way the abstraction looks, but haven't quite > > figured out how it should look like. > > Yeah, it's hard part, but we need to invent something in this area... I agree. But I really don't yet quite now what. I somewhat wonder if we should just add a cluster_rel() callback to the tableam and let it deal with everything :(. As previously proposed the interface wouldn't have worked with anything not losslessly encodable into a heaptuple, which is unlikely to be sufficient. FWIW, I plan to be mostly out until Thursday this week, and then I'll rebase onto the new version of the abstract slot patch and then try to split up the patchset. Once that's done, I'll do a prototype conversion of zheap, which I'm sure will show up a lot of weaknesses in the current abstraction. Once that's done I hope we can collaborate / divide & conquer to get the individual pieces into commit shape. If either of you wants to get a head start separating something out, let's try to organize who would do what? The EPQ and trigger slotification are probably good candidates. Greetings, Andres Freund
Commits
-
Add default_table_access_method to postgresql.conf.sample.
- 3a5c08aa0267 12.0 landed
- f7db0ac7d5b6 13.0 landed
-
tableam: Avoid relying on relation size to determine validity of tids.
- 147e3722f7e5 12.0 landed
-
tableam: Don't assume that every AM uses md.c style storage.
- 7f44ede59414 12.0 landed
-
Allow pg_class xid & multixid horizons to not be set.
- fdc7efcc30b1 12.0 landed
-
Fix slot type issue for fuzzy distance index scan over out-of-core table AM.
- b8b94ea129ff 12.0 cited
-
tableam: comment and formatting fixes.
- 6421011ea24d 12.0 landed
-
table: docs: fix typos and grammar.
- 86cc06d1cf9c 12.0 landed
-
tableam: basic documentation.
- b73c3a11963c 12.0 landed
-
Only allow heap in a number of contrib modules.
- 4b82664156c2 12.0 landed
-
tableam: Add table_finish_bulk_insert().
- d45e40158623 12.0 landed
-
tableam: sample scan.
- 73c954d24896 12.0 landed
-
tableam: bitmap table scan.
- bfbcad478f05 12.0 landed
-
tableam: Move heap specific logic from estimate_rel_size below tableam.
- 696d78469f37 12.0 landed
-
tableam: VACUUM and ANALYZE support.
- 737a292b5de2 12.0 landed
-
tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE.
- d25f519107bf 12.0 landed
-
tableam: Support for an index build's initial table scan(s).
- 2a96909a4a8c 12.0 landed
-
tableam: Add table_get_latest_tid, to wrap heap_get_latest_tid.
- 2e3da03e9ee4 12.0 landed
-
tableam: Add helper for indexes to check if a corresponding table tuples exist.
- 71bdc99d0d7c 12.0 landed
-
tableam: Add and use table_fetch_row_version().
- 9a8ee1dc650b 12.0 landed
-
tableam: Use in CREATE TABLE AS and CREATE MATERIALIZED VIEW.
- 919e48b94301 12.0 landed
-
Ensure sufficient alignment for ParallelTableScanDescData in BTShared.
- 8cacea7a7251 12.0 landed
-
Don't reuse slots between root and partition in ON CONFLICT ... UPDATE.
- 277cb789836b 12.0 landed
-
Use a virtual rather than a heap slot in two places where that suffices.
- 70b9bda65f81 12.0 landed
-
Store tuples for EvalPlanQual in slots, rather than as HeapTuples.
- ad0bda5d24ea 12.0 landed
-
Use slots in trigger infrastructure, except for the actual invocation.
- ff11e7f4b9ae 12.0 landed
-
Store table oid and tuple's tid in tuple slots directly.
- b8d71745eac0 12.0 landed
-
Allow to use HeapTupleData embedded in [Buffer]HeapTupleTableSlot.
- 5408e233f066 12.0 landed
-
Add ExecStorePinnedBufferHeapTuple.
- 8aa02b52db11 12.0 landed
-
Add ArchiveOpts to pass options to ArchiveEntry
- f831d4accda0 12.0 cited
-
Rename RelationData.rd_amroutine to rd_indam.
- 346ed70b0ad7 12.0 landed
-
Rephrase references to "time qualification".
- ebcc7bf949ba 12.0 landed
-
Move remaining code from tqual.[ch] to heapam.h / heapam_visibility.c.
- c91560defc57 12.0 landed
-
Move generic snapshot related code from tqual.h to snapmgr.h.
- b7eda3e0e334 12.0 landed
-
Remove superfluous tqual.h includes.
- e7cc78ad43eb 12.0 landed
-
Don't duplicate parallel seqscan shmem sizing logic in nbtree.
- 90525d7b4e0f 12.0 landed
-
Move vacuumlazy.c into access/heap.
- 285d8e12055f 12.0 landed
-
Support parallel bitmap heap scans.
- f35742ccb7aa 10.0 cited