1. 16 Aug, 2021 1 commit
    • Alvaro Herrera's avatar
      Revert analyze support for partitioned tables · b3d24cc0
      Alvaro Herrera authored
      This reverts the following commits:
      1b5617eb Describe (auto-)analyze behavior for partitioned tables
      0e69f705 Set pg_class.reltuples for partitioned tables
      41badeab Document ANALYZE storage parameters for partitioned tables
      0827e8af autovacuum: handle analyze for partitioned tables
      
      There are efficiency issues in this code when handling databases with
      large numbers of partitions, and it doesn't look like there isn't any
      trivial way to handle those.  There are some other issues as well.  It's
      now too late in the cycle for nontrivial fixes, so we'll have to let
      Postgres 14 users continue to manually deal with ANALYZE their
      partitioned tables, and hopefully we can fix the issues for Postgres 15.
      
      I kept [most of] be280cda ("Don't reset relhasindex for partitioned
      tables on ANALYZE") because while we added it due to 0827e8af, it is
      a good bugfix in its own right, since it affects manual analyze as well
      as autovacuum-induced analyze, and there's no reason to revert it.
      
      I retained the addition of relkind 'p' to tables included by
      pg_stat_user_tables, because reverting that would require a catversion
      bump.
      Also, in pg14 only, I keep a struct member that was added to
      PgStat_TabStatEntry to avoid breaking compatibility with existing stat
      files.
      
      Backpatch to 14.
      
      Discussion: https://postgr.es/m/20210722205458.f2bug3z6qzxzpx2s@alap3.anarazel.de
      b3d24cc0
  2. 14 May, 2021 1 commit
  3. 09 Apr, 2021 1 commit
  4. 06 Apr, 2021 1 commit
    • Fujii Masao's avatar
      Stop archive recovery if WAL generated with wal_level=minimal is found. · 9de9294b
      Fujii Masao authored
      Previously if hot standby was enabled, archive recovery exited with
      an error when it found WAL generated with wal_level=minimal.
      But if hot standby was disabled, it just reported a warning and
      continued in that case. Which could lead to data loss or errors
      during normal operation. A warning was emitted, but users could
      easily miss that and not notice this serious situation until
      they encountered the actual errors.
      
      To improve this situation, this commit changes archive recovery
      so that it exits with FATAL error when it finds WAL generated with
      wal_level=minimal whatever the setting of hot standby. This enables
      users to notice the serious situation soon.
      
      The FATAL error is thrown if archive recovery starts from a base
      backup taken before wal_level is changed to minimal. When archive
      recovery exits with the error, if users have a base backup taken
      after setting wal_level to higher than minimal, they can recover
      the database by starting archive recovery from that newer backup.
      But note that if such backup doesn't exist, there is no easy way to
      complete archive recovery, which may make the database server
      unstartable and users may lose whole database. The commit adds
      the note about this risk into the document.
      
      Even in the case of unstartable database server, previously by just
      disabling hot standby users could avoid the error during archive
      recovery, forcibly start up the server and salvage data from it.
      But note that this commit makes this procedure unavailable at all.
      
      Author: Takamichi Osumi
      Reviewed-by: Laurenz Albe, Kyotaro Horiguchi, David Steele, Fujii Masao
      Discussion: https://postgr.es/m/OSBPR01MB4888CBE1DA08818FD2D90ED8EDF90@OSBPR01MB4888.jpnprd01.prod.outlook.com
      9de9294b
  5. 31 Mar, 2021 1 commit
    • Tom Lane's avatar
      Rework planning and execution of UPDATE and DELETE. · 86dc9005
      Tom Lane authored
      This patch makes two closely related sets of changes:
      
      1. For UPDATE, the subplan of the ModifyTable node now only delivers
      the new values of the changed columns (i.e., the expressions computed
      in the query's SET clause) plus row identity information such as CTID.
      ModifyTable must re-fetch the original tuple to merge in the old
      values of any unchanged columns.  The core advantage of this is that
      the changed columns are uniform across all tables of an inherited or
      partitioned target relation, whereas the other columns might not be.
      A secondary advantage, when the UPDATE involves joins, is that less
      data needs to pass through the plan tree.  The disadvantage of course
      is an extra fetch of each tuple to be updated.  However, that seems to
      be very nearly free in context; even worst-case tests don't show it to
      add more than a couple percent to the total query cost.  At some point
      it might be interesting to combine the re-fetch with the tuple access
      that ModifyTable must do anyway to mark the old tuple dead; but that
      would require a good deal of refactoring and it seems it wouldn't buy
      all that much, so this patch doesn't attempt it.
      
      2. For inherited UPDATE/DELETE, instead of generating a separate
      subplan for each target relation, we now generate a single subplan
      that is just exactly like a SELECT's plan, then stick ModifyTable
      on top of that.  To let ModifyTable know which target relation a
      given incoming row refers to, a tableoid junk column is added to
      the row identity information.  This gets rid of the horrid hack
      that was inheritance_planner(), eliminating O(N^2) planning cost
      and memory consumption in cases where there were many unprunable
      target relations.
      
      Point 2 of course requires point 1, so that there is a uniform
      definition of the non-junk columns to be returned by the subplan.
      We can't insist on uniform definition of the row identity junk
      columns however, if we want to keep the ability to have both
      plain and foreign tables in a partitioning hierarchy.  Since
      it wouldn't scale very far to have every child table have its
      own row identity column, this patch includes provisions to merge
      similar row identity columns into one column of the subplan result.
      In particular, we can merge the whole-row Vars typically used as
      row identity by FDWs into one column by pretending they are type
      RECORD.  (It's still okay for the actual composite Datums to be
      labeled with the table's rowtype OID, though.)
      
      There is more that can be done to file down residual inefficiencies
      in this patch, but it seems to be committable now.
      
      FDW authors should note several API changes:
      
      * The argument list for AddForeignUpdateTargets() has changed, and so
      has the method it must use for adding junk columns to the query.  Call
      add_row_identity_var() instead of manipulating the parse tree directly.
      You might want to reconsider exactly what you're adding, too.
      
      * PlanDirectModify() must now work a little harder to find the
      ForeignScan plan node; if the foreign table is part of a partitioning
      hierarchy then the ForeignScan might not be the direct child of
      ModifyTable.  See postgres_fdw for sample code.
      
      * To check whether a relation is a target relation, it's no
      longer sufficient to compare its relid to root->parse->resultRelation.
      Instead, check it against all_result_relids or leaf_result_relids,
      as appropriate.
      
      Amit Langote and Tom Lane
      
      Discussion: https://postgr.es/m/CA+HiwqHpHdqdDn48yCEhynnniahH78rwcrv1rEX65-fsZGBOLQ@mail.gmail.com
      86dc9005
  6. 20 Jan, 2021 1 commit
  7. 03 Oct, 2020 1 commit
    • Peter Eisentraut's avatar
      Improve <xref> vs. <command> formatting in the documentation · 9081bddb
      Peter Eisentraut authored
      SQL commands are generally marked up as <command>, except when a link
      to a reference page is used using <xref>.  But the latter doesn't
      create monospace markup, so this looks strange especially when a
      paragraph contains a mix of links and non-links.
      
      We considered putting <command> in the <refentrytitle> on the target
      side, but that creates some formatting side effects elsewhere.
      Generally, it seems safer to solve this on the link source side.
      
      We can't put the <xref> inside the <command>; the DTD doesn't allow
      this.  DocBook 5 would allow the <command> to have the linkend
      attribute itself, but we are not there yet.
      
      So to solve this for now, convert the <xref>s to <link> plus
      <command>.  This gives the correct look and also gives some more
      flexibility what we can put into the link text (e.g., subcommands or
      other clauses).  In the future, these could then be converted to
      DocBook 5 style.
      
      I haven't converted absolutely all xrefs to SQL command reference
      pages, only those where we care about the appearance of the link text
      or where it was otherwise appropriate to make the appearance match a
      bit better.  Also in some cases, the links where repetitive, so in
      those cases the links where just removed and replaced by a plain
      <command>.  In cases where we just want the link and don't
      specifically care about the generated link text (typically phrased
      "for further information see <xref ...>") the xref is kept.
      Reported-by: default avatarDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
      Discussion: https://www.postgresql.org/message-id/flat/87o8pco34z.fsf@wibble.ilmari.org
      9081bddb
  8. 31 Aug, 2020 1 commit
  9. 14 May, 2020 1 commit
  10. 14 Apr, 2020 1 commit
  11. 06 Apr, 2020 1 commit
    • 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
  12. 04 Apr, 2020 1 commit
    • Noah Misch's avatar
      Skip WAL for new relfilenodes, under wal_level=minimal. · c6b92041
      Noah Misch authored
      Until now, only selected bulk operations (e.g. COPY) did this.  If a
      given relfilenode received both a WAL-skipping COPY and a WAL-logged
      operation (e.g. INSERT), recovery could lose tuples from the COPY.  See
      src/backend/access/transam/README section "Skipping WAL for New
      RelFileNode" for the new coding rules.  Maintainers of table access
      methods should examine that section.
      
      To maintain data durability, just before commit, we choose between an
      fsync of the relfilenode and copying its contents to WAL.  A new GUC,
      wal_skip_threshold, guides that choice.  If this change slows a workload
      that creates small, permanent relfilenodes under wal_level=minimal, try
      adjusting wal_skip_threshold.  Users setting a timeout on COMMIT may
      need to adjust that timeout, and log_min_duration_statement analysis
      will reflect time consumption moving to COMMIT from commands like COPY.
      
      Internally, this requires a reliable determination of whether
      RollbackAndReleaseCurrentSubTransaction() would unlink a relation's
      current relfilenode.  Introduce rd_firstRelfilenodeSubid.  Amend the
      specification of rd_createSubid such that the field is zero when a new
      rel has an old rd_node.  Make relcache.c retain entries for certain
      dropped relations until end of transaction.
      
      Bump XLOG_PAGE_MAGIC, since this introduces XLOG_GIST_ASSIGN_LSN.
      Future servers accept older WAL, so this bump is discretionary.
      
      Kyotaro Horiguchi, reviewed (in earlier, similar versions) by Robert
      Haas.  Heikki Linnakangas and Michael Paquier implemented earlier
      designs that materially clarified the problem.  Reviewed, in earlier
      designs, by Andrew Dunstan, Andres Freund, Alvaro Herrera, Tom Lane,
      Fujii Masao, and Simon Riggs.  Reported by Martijn van Oosterhout.
      
      Discussion: https://postgr.es/m/20150702220524.GA9392@svana.org
      c6b92041
  13. 22 Mar, 2020 1 commit
  14. 21 Mar, 2020 1 commit
    • Noah Misch's avatar
      Skip WAL for new relfilenodes, under wal_level=minimal. · cb2fd7ea
      Noah Misch authored
      Until now, only selected bulk operations (e.g. COPY) did this.  If a
      given relfilenode received both a WAL-skipping COPY and a WAL-logged
      operation (e.g. INSERT), recovery could lose tuples from the COPY.  See
      src/backend/access/transam/README section "Skipping WAL for New
      RelFileNode" for the new coding rules.  Maintainers of table access
      methods should examine that section.
      
      To maintain data durability, just before commit, we choose between an
      fsync of the relfilenode and copying its contents to WAL.  A new GUC,
      wal_skip_threshold, guides that choice.  If this change slows a workload
      that creates small, permanent relfilenodes under wal_level=minimal, try
      adjusting wal_skip_threshold.  Users setting a timeout on COMMIT may
      need to adjust that timeout, and log_min_duration_statement analysis
      will reflect time consumption moving to COMMIT from commands like COPY.
      
      Internally, this requires a reliable determination of whether
      RollbackAndReleaseCurrentSubTransaction() would unlink a relation's
      current relfilenode.  Introduce rd_firstRelfilenodeSubid.  Amend the
      specification of rd_createSubid such that the field is zero when a new
      rel has an old rd_node.  Make relcache.c retain entries for certain
      dropped relations until end of transaction.
      
      Back-patch to 9.5 (all supported versions).  This introduces a new WAL
      record type, XLOG_GIST_ASSIGN_LSN, without bumping XLOG_PAGE_MAGIC.  As
      always, update standby systems before master systems.  This changes
      sizeof(RelationData) and sizeof(IndexStmt), breaking binary
      compatibility for affected extensions.  (The most recent commit to
      affect the same class of extensions was
      089e4d405d0f3b94c74a2c6a54357a84a681754b.)
      
      Kyotaro Horiguchi, reviewed (in earlier, similar versions) by Robert
      Haas.  Heikki Linnakangas and Michael Paquier implemented earlier
      designs that materially clarified the problem.  Reviewed, in earlier
      designs, by Andrew Dunstan, Andres Freund, Alvaro Herrera, Tom Lane,
      Fujii Masao, and Simon Riggs.  Reported by Martijn van Oosterhout.
      
      Discussion: https://postgr.es/m/20150702220524.GA9392@svana.org
      cb2fd7ea
  15. 14 Mar, 2020 1 commit
    • Tomas Vondra's avatar
      Use functional dependencies to estimate ScalarArrayOpExpr · 8f321bd1
      Tomas Vondra authored
      Until now functional dependencies supported only simple equality clauses
      and clauses that can be trivially translated to equalities. This commit
      allows estimation of some ScalarArrayOpExpr (IN/ANY) clauses.
      
      For IN clauses we can do this thanks to using operator with equality
      semantics, which means an IN clause
      
          WHERE c IN (1, 2, ..., N)
      
      can be translated to
      
          WHERE (c = 1 OR c = 2 OR ... OR c = N)
      
      IN clauses are now considered compatible with functional dependencies,
      and rely on the same assumption of consistency of queries with data
      (which is an assumption we already used for simple equality clauses).
      This applies also to ALL clauses with an equality operator, which can be
      considered equivalent to IN clause.
      
      ALL clauses are still considered incompatible, although there's some
      discussion about maybe relaxing this in the future.
      
      Author: Pierre Ducroquet
      Reviewed-by: Tomas Vondra, Dean Rasheed
      Discussion: https://www.postgresql.org/message-id/flat/13902317.Eha0YfKkKy%40pierred-pdoc
      8f321bd1
  16. 08 Dec, 2019 1 commit
  17. 30 Sep, 2019 1 commit
  18. 08 Sep, 2019 1 commit
  19. 15 Jun, 2019 1 commit
    • Tomas Vondra's avatar
      Rework the pg_statistic_ext catalog · 6cbfb784
      Tomas Vondra authored
      Since extended statistic got introduced in PostgreSQL 10, there was a
      single catalog pg_statistic_ext storing both the definitions and built
      statistic.  That's however problematic when a user is supposed to have
      access only to the definitions, but not to user data.
      
      Consider for example pg_dump on a database with RLS enabled - if the
      pg_statistic_ext catalog respects RLS (which it should, if it contains
      user data), pg_dump would not see any records and the result would not
      define any extended statistics.  That would be a surprising behavior.
      
      Until now this was not a pressing issue, because the existing types of
      extended statistic (functional dependencies and ndistinct coefficients)
      do not include any user data directly.  This changed with introduction
      of MCV lists, which do include most common combinations of values.
      
      The easiest way to fix this is to split the pg_statistic_ext catalog
      into two - one for definitions, one for the built statistic values.
      The new catalog is called pg_statistic_ext_data, and we're maintaining
      a 1:1 relationship with the old catalog - either there are matching
      records in both catalogs, or neither of them.
      
      Bumped CATVERSION due to changing system catalog definitions.
      
      Author: Dean Rasheed, with improvements by me
      Reviewed-by: Dean Rasheed, John Naylor
      Discussion: https://postgr.es/m/CAEZATCUhT9rt7Ui%3DVdx4N%3D%3DVV5XOK5dsXfnGgVOz_JhAicB%3DZA%40mail.gmail.com
      6cbfb784
  20. 27 Mar, 2019 1 commit
    • Tomas Vondra's avatar
      Add support for multivariate MCV lists · 7300a699
      Tomas Vondra authored
      Introduce a third extended statistic type, supported by the CREATE
      STATISTICS command - MCV lists, a generalization of the statistic
      already built and used for individual columns.
      
      Compared to the already supported types (n-distinct coefficients and
      functional dependencies), MCV lists are more complex, include column
      values and allow estimation of much wider range of common clauses
      (equality and inequality conditions, IS NULL, IS NOT NULL etc.).
      Similarly to the other types, a new pseudo-type (pg_mcv_list) is used.
      
      Author: Tomas Vondra
      Reviewed-by: Dean Rasheed, David Rowley, Mark Dilger, Alvaro Herrera
      Discussion: https://postgr.es/m/dfdac334-9cf2-2597-fb27-f0fb3753f435@2ndquadrant.com
      7300a699
  21. 06 Dec, 2018 1 commit
  22. 19 Nov, 2018 1 commit
    • Alvaro Herrera's avatar
      Disallow COPY FREEZE on partitioned tables · 5c9a5513
      Alvaro Herrera authored
      This didn't actually work: COPY would fail to flush the right files, and
      instead would try to flush a non-existing file, causing the whole
      transaction to fail.
      
      Cope by raising an error as soon as the command is sent instead, to
      avoid a nasty later surprise.  Of course, it would be much better to
      make it work, but we don't have a patch for that yet, and we don't know
      if we'll want to backpatch one when we do.
      
      Reported-by: Tomas Vondra
      Author: David Rowley
      Reviewed-by: Amit Langote, Steve Singer, Tomas Vondra
      5c9a5513
  23. 19 Jul, 2018 1 commit
  24. 07 Apr, 2018 1 commit
    • Alvaro Herrera's avatar
      Support partition pruning at execution time · 499be013
      Alvaro Herrera authored
      Existing partition pruning is only able to work at plan time, for query
      quals that appear in the parsed query.  This is good but limiting, as
      there can be parameters that appear later that can be usefully used to
      further prune partitions.
      
      This commit adds support for pruning subnodes of Append which cannot
      possibly contain any matching tuples, during execution, by evaluating
      Params to determine the minimum set of subnodes that can possibly match.
      We support more than just simple Params in WHERE clauses. Support
      additionally includes:
      
      1. Parameterized Nested Loop Joins: The parameter from the outer side of the
         join can be used to determine the minimum set of inner side partitions to
         scan.
      
      2. Initplans: Once an initplan has been executed we can then determine which
         partitions match the value from the initplan.
      
      Partition pruning is performed in two ways.  When Params external to the plan
      are found to match the partition key we attempt to prune away unneeded Append
      subplans during the initialization of the executor.  This allows us to bypass
      the initialization of non-matching subplans meaning they won't appear in the
      EXPLAIN or EXPLAIN ANALYZE output.
      
      For parameters whose value is only known during the actual execution
      then the pruning of these subplans must wait.  Subplans which are
      eliminated during this stage of pruning are still visible in the EXPLAIN
      output.  In order to determine if pruning has actually taken place, the
      EXPLAIN ANALYZE must be viewed.  If a certain Append subplan was never
      executed due to the elimination of the partition then the execution
      timing area will state "(never executed)".  Whereas, if, for example in
      the case of parameterized nested loops, the number of loops stated in
      the EXPLAIN ANALYZE output for certain subplans may appear lower than
      others due to the subplan having been scanned fewer times.  This is due
      to the list of matching subnodes having to be evaluated whenever a
      parameter which was found to match the partition key changes.
      
      This commit required some additional infrastructure that permits the
      building of a data structure which is able to perform the translation of
      the matching partition IDs, as returned by get_matching_partitions, into
      the list index of a subpaths list, as exist in node types such as
      Append, MergeAppend and ModifyTable.  This allows us to translate a list
      of clauses into a Bitmapset of all the subpath indexes which must be
      included to satisfy the clause list.
      
      Author: David Rowley, based on an earlier effort by Beena Emerson
      Reviewers: Amit Langote, Robert Haas, Amul Sul, Rajkumar Raghuwanshi,
      Jesper Pedersen
      Discussion: https://postgr.es/m/CAOG9ApE16ac-_VVZVvv0gePSgkg_BwYEV1NBqZFqDR2bBE0X0A@mail.gmail.com
      499be013
  25. 18 Dec, 2017 1 commit
  26. 23 Nov, 2017 1 commit
    • Peter Eisentraut's avatar
      Convert documentation to DocBook XML · 3c49c6fa
      Peter Eisentraut authored
      Since some preparation work had already been done, the only source
      changes left were changing empty-element tags like <xref linkend="foo">
      to <xref linkend="foo"/>, and changing the DOCTYPE.
      
      The source files are still named *.sgml, but they are actually XML files
      now.  Renaming could be considered later.
      
      In the build system, the intermediate step to convert from SGML to XML
      is removed.  Everything is build straight from the source files again.
      The OpenSP (or the old SP) package is no longer needed.
      
      The documentation toolchain instructions are updated and are much
      simpler now.
      
      Peter Eisentraut, Alexander Lakhin, Jürgen Purtz
      3c49c6fa
  27. 20 Oct, 2017 1 commit
    • Peter Eisentraut's avatar
      Convert SGML IDs to lower case · 1ff01b39
      Peter Eisentraut authored
      IDs in SGML are case insensitive, and we have accumulated a mix of upper
      and lower case IDs, including different variants of the same ID.  In
      XML, these will be case sensitive, so we need to fix up those
      differences.  Going to all lower case seems most straightforward, and
      the current build process already makes all anchors and lower case
      anyway during the SGML->XML conversion, so this doesn't create any
      difference in the output right now.  A future XML-only build process
      would, however, maintain any mixed case ID spellings in the output, so
      that is another reason to clean this up beforehand.
      
      Author: Alexander Lakhin <exclusion@gmail.com>
      1ff01b39
  28. 17 Oct, 2017 1 commit
    • Peter Eisentraut's avatar
      Don't use SGML empty tags · c29c5789
      Peter Eisentraut authored
      For DocBook XML compatibility, don't use SGML empty tags (</>) anymore,
      replace by the full tag name.  Add a warning option to catch future
      occurrences.
      
      Alexander Lakhin, Jürgen Purtz
      c29c5789
  29. 11 Sep, 2017 1 commit
  30. 02 Sep, 2017 1 commit
  31. 18 Jun, 2017 1 commit
  32. 14 May, 2017 1 commit
  33. 12 May, 2017 1 commit
    • Alvaro Herrera's avatar
      Change CREATE STATISTICS syntax · bc085205
      Alvaro Herrera authored
      Previously, we had the WITH clause in the middle of the command, where
      you'd specify both generic options as well as statistic types.  Few
      people liked this, so this commit changes it to remove the WITH keyword
      from that clause and makes it accept statistic types only.  (We
      currently don't have any generic options, but if we invent in the
      future, we will gain a new WITH clause, probably at the end of the
      command).
      
      Also, the column list is now specified without parens, which makes the
      whole command look more similar to a SELECT command.  This change will
      let us expand the command to supporting expressions (not just columns
      names) as well as multiple tables and their join conditions.
      
      Tom added lots of code comments and fixed some parts of the CREATE
      STATISTICS reference page, too; more changes in this area are
      forthcoming.  He also fixed a potential problem in the alter_generic
      regression test, reducing verbosity on a cascaded drop to avoid
      dependency on message ordering, as we do in other tests.
      
      Tom also closed a security bug: we documented that table ownership was
      required in order to create a statistics object on it, but didn't
      actually implement it.
      
      Implement tab-completion for statistics objects.  This can stand some
      more improvement.
      
      Authors: Alvaro Herrera, with lots of cleanup by Tom Lane
      Discussion: https://postgr.es/m/20170420212426.ltvgyhnefvhixm6i@alvherre.pgsql
      bc085205
  34. 02 May, 2017 1 commit
  35. 20 Apr, 2017 1 commit
    • Alvaro Herrera's avatar
      Improve multivariate statistics documentation · 919f6d74
      Alvaro Herrera authored
      Extended statistics commit 7b504eb2 did not include appropriate
      documentation next to where we document regular planner statistics (I
      ripped what was submitted before commit and then forgot to put it back),
      and while later commit 2686ee1b added some material, it structurally
      depended on what I had ripped out, so the end result wasn't proper.
      
      Fix those problems by shuffling what was added by 2686ee1b and
      including some additional material, so that now chapter 14 "Performance
      Tips" now describes the types of multivariate statistics we currently
      have, and chapter 68 "How the Planner Uses Statistics" shows some
      examples.  The new text should be more in line with previous material,
      in (hopefully) the appropriate depth.
      
      While at it, fix a small bug in pg_statistic_ext docs: one column was
      listed in the wrong spot.
      919f6d74
  36. 20 Oct, 2016 1 commit
    • Robert Haas's avatar
      Rename "pg_xlog" directory to "pg_wal". · f82ec32a
      Robert Haas authored
      "xlog" is not a particularly clear abbreviation for "write-ahead log",
      and it sometimes confuses users into believe that the contents of the
      "pg_xlog" directory are not critical data, leading to unpleasant
      consequences.  So, rename the directory to "pg_wal".
      
      This patch modifies pg_upgrade and pg_basebackup to understand both
      the old and new directory layouts; the former is necessary given the
      purpose of the tool, while the latter merely avoids an unnecessary
      backward-compatibility break.
      
      We may wish to consider renaming other programs, switches, and
      functions which still use the old "xlog" naming to also refer to
      "wal".  However, that's still under discussion, so let's do just this
      much for now.
      
      Discussion: CAB7nPqTeC-8+zux8_-4ZD46V7YPwooeFxgndfsq5Rg8ibLVm1A@mail.gmail.com
      
      Michael Paquier
      f82ec32a
  37. 22 Mar, 2015 1 commit
    • Tom Lane's avatar
      Allow foreign tables to participate in inheritance. · cb1ca4d8
      Tom Lane authored
      Foreign tables can now be inheritance children, or parents.  Much of the
      system was already ready for this, but we had to fix a few things of
      course, mostly in the area of planner and executor handling of row locks.
      
      As side effects of this, allow foreign tables to have NOT VALID CHECK
      constraints (and hence to accept ALTER ... VALIDATE CONSTRAINT), and to
      accept ALTER SET STORAGE and ALTER SET WITH/WITHOUT OIDS.  Continuing to
      disallow these things would've required bizarre and inconsistent special
      cases in inheritance behavior.  Since foreign tables don't enforce CHECK
      constraints anyway, a NOT VALID one is a complete no-op, but that doesn't
      mean we shouldn't allow it.  And it's possible that some FDWs might have
      use for SET STORAGE or SET WITH OIDS, though doubtless they will be no-ops
      for most.
      
      An additional change in support of this is that when a ModifyTable node
      has multiple target tables, they will all now be explicitly identified
      in EXPLAIN output, for example:
      
       Update on pt1  (cost=0.00..321.05 rows=3541 width=46)
         Update on pt1
         Foreign Update on ft1
         Foreign Update on ft2
         Update on child3
         ->  Seq Scan on pt1  (cost=0.00..0.00 rows=1 width=46)
         ->  Foreign Scan on ft1  (cost=100.00..148.03 rows=1170 width=46)
         ->  Foreign Scan on ft2  (cost=100.00..148.03 rows=1170 width=46)
         ->  Seq Scan on child3  (cost=0.00..25.00 rows=1200 width=46)
      
      This was done mainly to provide an unambiguous place to attach "Remote SQL"
      fields, but it is useful for inherited updates even when no foreign tables
      are involved.
      
      Shigeru Hanada and Etsuro Fujita, reviewed by Ashutosh Bapat and Kyotaro
      Horiguchi, some additional hacking by me
      cb1ca4d8
  38. 23 Feb, 2015 1 commit
    • Heikki Linnakangas's avatar
      Replace checkpoint_segments with min_wal_size and max_wal_size. · 88e98230
      Heikki Linnakangas authored
      Instead of having a single knob (checkpoint_segments) that both triggers
      checkpoints, and determines how many checkpoints to recycle, they are now
      separate concerns. There is still an internal variable called
      CheckpointSegments, which triggers checkpoints. But it no longer determines
      how many segments to recycle at a checkpoint. That is now auto-tuned by
      keeping a moving average of the distance between checkpoints (in bytes),
      and trying to keep that many segments in reserve. The advantage of this is
      that you can set max_wal_size very high, but the system won't actually
      consume that much space if there isn't any need for it. The min_wal_size
      sets a floor for that; you can effectively disable the auto-tuning behavior
      by setting min_wal_size equal to max_wal_size.
      
      The max_wal_size setting is now the actual target size of WAL at which a
      new checkpoint is triggered, instead of the distance between checkpoints.
      Previously, you could calculate the actual WAL usage with the formula
      "(2 + checkpoint_completion_target) * checkpoint_segments + 1". With this
      patch, you set the desired WAL usage with max_wal_size, and the system
      calculates the appropriate CheckpointSegments with the reverse of that
      formula. That's a lot more intuitive for administrators to set.
      
      Reviewed by Amit Kapila and Venkata Balaji N.
      88e98230
  39. 15 Oct, 2014 1 commit
    • Tom Lane's avatar
      Print planning time only in EXPLAIN ANALYZE, not plain EXPLAIN. · 90063a76
      Tom Lane authored
      We've gotten enough push-back on that change to make it clear that it
      wasn't an especially good idea to do it like that.  Revert plain EXPLAIN
      to its previous behavior, but keep the extra output in EXPLAIN ANALYZE.
      Per discussion.
      
      Internally, I set this up as a separate flag ExplainState.summary that
      controls printing of planning time and execution time.  For now it's
      just copied from the ANALYZE option, but we could consider exposing it
      to users.
      90063a76
  40. 17 Jul, 2014 1 commit