1. 08 Apr, 2020 21 commits
  2. 07 Apr, 2020 14 commits
  3. 06 Apr, 2020 5 commits
    • Tomas Vondra's avatar
      Use INT64_FORMAT when formatting int64 values in explain · 4bea576b
      Tomas Vondra authored
      Per report from lapwing.
      4bea576b
    • Tomas Vondra's avatar
      Fix failures in incremental_sort due to number of workers · 23ba3b5e
      Tomas Vondra authored
      The last test in incremental_sort suite prints a parallel plan, but some
      of the buildfarm animals have custom max_parallel_workers_per_gather
      values, causing failures. Fixed by setting the GUC to an explicit value.
      
      Discussion: https://postgr.es/m/CAPpHfds1waRZ=NOmueYq0sx1ZSCnt+5QJvizT8ndT2=etZEeAQ@mail.gmail.com
      23ba3b5e
    • Peter Geoghegan's avatar
      Fix nbtree kill_prior_tuple posting list assert. · ce2cee0a
      Peter Geoghegan authored
      An assertion added by commit 0d861bbb checked that _bt_killitems() only
      processes a BTScanPosItem whose heap TID is contained in a posting list
      tuple when its page offset number still matches what is on the page
      (i.e. when it matches the posting list tuple's current offset number).
      This was only correct in the common case where the page can't have
      changed since we first read it.  It was not correct in cases where we
      don't drop the buffer pin (and don't need to verify the page hasn't
      changed using its LSN).  The latter category includes scans involving
      unlogged tables, and scans that use a non-MVCC snapshot, per the logic
      originally introduced by commit 2ed5b87f.
      
      The assertion still seems helpful.  Fix it by taking cases where the
      page may have been concurrently modified into account.
      
      Reported-By: Anastasia Lubennikova, Alexander Lakhin
      Discussion: https://postgr.es/m/c4e38e9a-0f9c-8e53-e639-adf343f94472@postgrespro.ru
      ce2cee0a
    • Tomas Vondra's avatar
      Fix show_incremental_sort_info with force_parallel_mode · 7d6d82a5
      Tomas Vondra authored
      When executed with force_parallel_mode=regress, the function was exiting
      too early and thus failed to print the worker stats. Fixed by making it
      more like show_sort_info.
      
      Discussion: https://postgr.es/m/CAPpHfds1waRZ=NOmueYq0sx1ZSCnt+5QJvizT8ndT2=etZEeAQ@mail.gmail.com
      7d6d82a5
    • Tomas Vondra's avatar
      Implement Incremental Sort · d2d8a229
      Tomas Vondra authored
      Incremental Sort is an optimized variant of multikey sort for cases when
      the input is already sorted by a prefix of the requested sort keys. For
      example when the relation is already sorted by (key1, key2) and we need
      to sort it by (key1, key2, key3) we can simply split the input rows into
      groups having equal values in (key1, key2), and only sort/compare the
      remaining column key3.
      
      This has a number of benefits:
      
      - Reduced memory consumption, because only a single group (determined by
        values in the sorted prefix) needs to be kept in memory. This may also
        eliminate the need to spill to disk.
      
      - Lower startup cost, because Incremental Sort produce results after each
        prefix group, which is beneficial for plans where startup cost matters
        (like for example queries with LIMIT clause).
      
      We consider both Sort and Incremental Sort, and decide based on costing.
      
      The implemented algorithm operates in two different modes:
      
      - Fetching a minimum number of tuples without check of equality on the
        prefix keys, and sorting on all columns when safe.
      
      - Fetching all tuples for a single prefix group and then sorting by
        comparing only the remaining (non-prefix) keys.
      
      We always start in the first mode, and employ a heuristic to switch into
      the second mode if we believe it's beneficial - the goal is to minimize
      the number of unnecessary comparions while keeping memory consumption
      below work_mem.
      
      This is a very old patch series. The idea was originally proposed by
      Alexander Korotkov back in 2013, and then revived in 2017. In 2018 the
      patch was taken over by James Coleman, who wrote and rewrote most of the
      current code.
      
      There were many reviewers/contributors since 2013 - I've done my best to
      pick the most active ones, and listed them in this commit message.
      
      Author: James Coleman, Alexander Korotkov
      Reviewed-by: Tomas Vondra, Andreas Karlsson, Marti Raudsepp, Peter Geoghegan, Robert Haas, Thomas Munro, Antonin Houska, Andres Freund, Alexander Kuzmenkov
      Discussion: https://postgr.es/m/CAPpHfdscOX5an71nHd8WSUH6GNOCf=V7wgDaTXdDd9=goN-gfA@mail.gmail.com
      Discussion: https://postgr.es/m/CAPpHfds1waRZ=NOmueYq0sx1ZSCnt+5QJvizT8ndT2=etZEeAQ@mail.gmail.com
      d2d8a229