Thread

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. psql \dP: list partitioned tables and indexes

  1. psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-23T19:38:45Z

    Dear hackers,
    
    Please find attached the patch to add a new metacommand (\dh) to psql.
    I find the functionality very useful for my day-to-day job, and decided
    to add it to psql source code. Summary of the command, justification
    for adding the functionality, as well as design choices are listed
    below.
    
    Best Regards,
    Sadeq Dousti
    Tech Lead and Staff Software Engineer at Trade Republic Bank GmbH
    
    ================
    
    Summary
    ------------
    The \dh command provides a concise overview of high-level (root)
    relations, including tables and indexes. This helps DBAs and developers
    quickly identify the core structure of a database, particularly in
    environments with extensive partitioning. It offers two variants: \dht
    for only showing root tables, and \dhi for only showing root indexes.
    By adding the + option, additional details such as the total sizes of
    the relations are also displayed.
    
    
    Reference
    ------------
    Commit 1c5d927 (psql \dP metacommand) is used as the basis for this
    patch.
    
    Justification
    ------------
    In databases with partitioned tables, standard listing commands such as
    \dt can produce long and cluttered outputs due to the large number of
    partitions. The \dh command filters the output to show only root tables
    (both regular and partitioned) and high-level indexes, improving
    readability and usability.
    
    This enhancement allows users to:
    
    * Quickly scan the primary structure of a database without being
      overwhelmed by partitions.
    * View table ownership and optionally include size information.
    * Identify which indexes belong to which tables, along with
      descriptions.
    
    
    Comparison Example
    ------------
    Using \dt in a partitioned database results in an extensive list that
    includes all partitions:
    
    
    postgres=# \dt
                  List of tables
     Schema | Name |       Type        | Owner
    --------+------+-------------------+-------
     public | t    | table             | sadeq
     public | z    | partitioned table | sadeq
     public | z_1  | table             | sadeq
     public | z_2  | table             | sadeq
     public | z_3  | table             | sadeq
     public | z_4  | table             | sadeq
     public | z_5  | table             | sadeq
     public | z_6  | table             | sadeq
     public | z_7  | table             | sadeq
     public | z_8  | table             | sadeq
     public | z_9  | table             | sadeq
     public | z_10 | table             | sadeq
     public | z_11 | table             | sadeq
     public | z_12 | table             | sadeq
     public | z_13 | table             | sadeq
     public | z_14 | table             | sadeq
     public | z_15 | table             | sadeq
    
    
    The \dh command simplifies this view by displaying only the root tables:
    
    postgres=# \dht
      List of root tables
     Schema | Name | Owner
    --------+------+-------
     public | t    | sadeq
     public | z    | sadeq
    
    
    Design Decision: Introduction of the New Command \dh
    ------------
    In the development of the \dh command to list high-level (root) tables
    and indexes, it was initially considered to extend the existing \dP
    command to support this functionality. However, after evaluating the
    existing codebase, it became clear that adding this feature to \dP
    would introduce significant complexity and reduce code readability.
    Specifically, the following points led to the decision to implement a
    new command instead of extending \dP or \d variant:
    
    1. Functionality Mismatch: The \dP command is designed to display
       partitioned tables. Modifying it to also show non-partitioned table
       can potentially confuse the user.
    
    
    2. Additional Branching and Readability: Introducing additional
       functionality to support high-level (root) relations would require a
       substantial amount of branching logic, making the code more
       difficult to follow and potentially error-prone.
    
    3. Consistency with Existing \d Variants: Other \d variants exhibit a
       high degree of functional separation, with each command serving a
       unique role related to a specific type of database object. The logic
       for \dh is closer to \dP than any other \d variant, and it's already
       ruled out for the sake of readability.
    
    Given these factors, the decision was made to introduce a new command,
    \dh, to provide a concise overview of root tables and indexes. This
    approach ensures clarity, avoids unnecessary complexity, and maintains
    consistency with the overall design philosophy of psql metacommands.
    
    
    Further Details
    ------------
    * Patch is against the master branch
    * Code compiles successfully. New functionality is tested manually with
      success
    * Regression tests are added, and all existing and new tests pass
    * Documentation (psql-ref.sgml) is updated with details for \dh
    
  2. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-23T20:44:22Z

    Sorry an id was missing in psql documentation, thus CI was failing.
    Please find attached a patch that fixes this issue.
    
    Best Regards,
    Sadeq Dousti
    Tech Lead and Staff Software Engineer at Trade Republic Bank GmbH
    
  3. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Tom Lane <tgl@sss.pgh.pa.us> — 2025-02-23T20:47:09Z

    Sadeq Dousti <msdousti@gmail.com> writes:
    > Please find attached the patch to add a new metacommand (\dh) to psql.
    
    I don't have a strong feeling one way or the other about whether this
    is useful functionality or not.  But if we do want it, I'd like to
    bikeshed on the name a bit.  "High-level" is not terminology we use
    anywhere else, and it's ambiguous too (just how high in a partition
    tree does a table need to be to be listed?).  We do use the terms
    "root partition" or "partition root".  So I'd prefer something
    based on those terms.  Possibilities:
    
    1. Use "\dr" or maybe better "\dR" (letting \dr remain available for
    some future command about roles).  The trouble with either of these
    is that the name is already partially overloaded, since we already
    have \drds, \drg, \dRp, \dRs.
    
    2. Extend the existing \dP (display partitions) command with some
    flag that restricts the listing to root partitions, probably
    "r" for "root".
    
      \dP[itnx+] [PATTERN]   list [only index/table] partitioned relations [n=nested
    ]
    
    I kind of like #2 better, but am not set on it.
    
    While we're at it maybe we could bring some sanity to the "n"
    flag, which seems to have several bizarre properties like
    working differently depending on whether you give a pattern.
    It looks from this documentation like it's the inverse of what
    "r" would do, but testing says it's not.
    
    			regards, tom lane
    
    
    
    
  4. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-23T21:10:44Z

    > Sorry an id was missing in psql documentation, thus CI was failing.
    
    Combining patches into one, as otherwise CI does not combine them.
    
    Best Regards
    Sadeq Dousti
    
  5. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-23T21:26:42Z

    Hi Tom,
    
    Thanks a lot for looking into this!
    
    > "High-level" is not terminology we use anywhere else
    > We do use the terms "root partition" or "partition root".
    
    I agree "high-level" is not standard, but "root partition" also entails
    the table is actually partitioned. This is not necessarily the case.
    The suggested command will show all non-partitioned tables, plus the
    root partitions.
    
    So, in the example I provided, t is a non-partitioned table, and z is
    the root partition. The command shows them both:
    
    
    postgres=# \dht
      List of root tables
     Schema | Name | Owner
    --------+------+-------
     public | t    | sadeq
     public | z    | sadeq
    
    
    The reason I called them high-level is that they provide a
    high-level overview into the database table/index structure.
    
    
    > Extend the existing \dP (display partitions)
    I also thought about it at first, but that command is for displaying
    partitions, while I want the opposite: Don't display partitions at all.
    I tried to detail why I didn't use \dP or any existing \d commands
    in the first email of the thread (section "Design Decision").
    
    Best Regards,
    Sadeq Dousti
    
  6. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-23T21:34:30Z

    > That definition seems bizarre, and even less derivable
    > from the term "high-level" than what I thought you meant.
    > You really need some other terminology, I think.
    
    Totally agree about the naming. There's no other terminology known to
    me, but I'll definitely think about it. Of course, I'm very open to
    suggestions from you or anyone else in the community.
    
    The way we can think about the concept: these are "top" tables,
    regardless of whether they have children (partitions) or not.
    
    > (BTW, you forgot to cc the list, so nobody else saw this defense
    > of your idea.)
    
    Oops! Thanks for mentioning this. I sent the previous email to the list
    as well.
    
    Best Regards,
    Sadeq Dousti
    
  7. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Tom Lane <tgl@sss.pgh.pa.us> — 2025-02-23T21:38:59Z

    Sadeq Dousti <msdousti@gmail.com> writes:
    >> "High-level" is not terminology we use anywhere else
    >> We do use the terms "root partition" or "partition root".
    
    > I agree "high-level" is not standard, but "root partition" also entails
    > the table is actually partitioned. This is not necessarily the case.
    > The suggested command will show all non-partitioned tables, plus the
    > root partitions.
    
    Hmm, that seems even less derivable from the term "high-level"
    than what I thought you meant.  However, if that's the behavior
    you want, maybe we could extend "\d[ti...]" with an option that
    suppresses partition-tree members?  My first thought about that
    is "n" for "not a partition member", but maybe somebody else
    can invent a better name.  (One problem with "n" is that "\dn"
    without either "t" or "i" would mean something else.  Using "N"
    would fix that, but the capitalization seems a bit random.)
    
    Independently of that, extending \dP with an option for "roots
    only" seems like a good idea.  But that's a different patch.
    
    			regards, tom lane
    
    
    
    
  8. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Greg Sabino Mullane <htamfids@gmail.com> — 2025-02-23T23:30:36Z

    On Sun, Feb 23, 2025 at 4:34 PM Sadeq Dousti <msdousti@gmail.com> wrote:
    
    > Totally agree about the naming. There's no other terminology known to me,
    > but I'll definitely think about it. Of course, I'm very open to
    > suggestions from you or anyone else in the community.
    >
    
    The problem is that we are really tight on available letters for a bare \d.
    I immediately thought of "adult" tables (those that are not children). But
    both \da and \dA are used! The only other mnemonic option is "\de" where e
    stands for elder tables (get it? elder because they are not children).
    
    Would it be useful to you to have them as separate items? In other words,
    not indexes and tables together, but some flag on both \dt and \di to limit
    to non-child relations. I think as far as "core structure" the list of
    tables is far more important than what indexes happen to be on them. Plus,
    \d also shows sequences, which is even less useful information than
    indexes, IMHO.
    
    So maybe \dta and \dia? (adults only)
    
    Cheers,
    Greg
    
    --
    Crunchy Data - https://www.crunchydata.com
    Enterprise Postgres Software Products & Tech Support
    
  9. Re: psql \dh: List High-Level (Root) Tables and Indexes

    David G. Johnston <david.g.johnston@gmail.com> — 2025-02-24T00:40:09Z

    On Sun, Feb 23, 2025 at 4:31 PM Greg Sabino Mullane <htamfids@gmail.com>
    wrote:
    
    > On Sun, Feb 23, 2025 at 4:34 PM Sadeq Dousti <msdousti@gmail.com> wrote:
    >
    >> Totally agree about the naming. There's no other terminology known to me,
    >> but I'll definitely think about it. Of course, I'm very open to
    >> suggestions from you or anyone else in the community.
    >>
    >
    > The problem is that we are really tight on available letters for a
    > bare \d. I immediately thought of "adult" tables (those that are not
    > children). But both \da and \dA are used! The only other mnemonic option is
    > "\de" where e stands for elder tables (get it? elder because they are not
    > children).
    >
    >
    How about:
    \pset partition_roots_only 'true'
    
    Then update all relevant queries to respect it.
    
    That way no learning new ways to get the information you want but instead
    can set a global filter to suppress those child nodes that really don't
    need to be seen normally.
    
    It would be nice if "N partition children suppressed due to
    partition_roots_only" would appear in the output somewhere if going this
    direction.
    
    David J.
    
  10. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Tom Lane <tgl@sss.pgh.pa.us> — 2025-02-24T05:16:04Z

    "David G. Johnston" <david.g.johnston@gmail.com> writes:
    > How about:
    > \pset partition_roots_only 'true'
    
    FWIW, I don't especially love this idea.  None of our existing
    \d-type commands use pset parameters for filtering, and I don't
    see a reason to believe that people would typically want this
    to be a persistent setting.  I'd guess that sometimes you want
    the tables filtered one way and sometimes the other.
    
    			regards, tom lane
    
    
    
    
  11. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Pavel Stehule <pavel.stehule@gmail.com> — 2025-02-24T06:22:15Z

    po 24. 2. 2025 v 6:16 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
    
    > "David G. Johnston" <david.g.johnston@gmail.com> writes:
    > > How about:
    > > \pset partition_roots_only 'true'
    >
    > FWIW, I don't especially love this idea.  None of our existing
    > \d-type commands use pset parameters for filtering, and I don't
    > see a reason to believe that people would typically want this
    > to be a persistent setting.  I'd guess that sometimes you want
    > the tables filtered one way and sometimes the other.
    >
    
    There can be numeric parameter that can specify the deep - some like
    
    \dP 0
    
    Regards
    
    Pavel
    
    >
    >                         regards, tom lane
    >
    >
    >
    
  12. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-24T08:07:09Z

    Dear all,
    
    I'm grateful for taking your time and providing various solutions!
    
    Personally, I like Tom's idea of using N better:
    
    * It can stand for "not a partition member" or "no partitions", and does
    not provide any new terminology.
    * It can be combined with various commands \dN, \dtN (or \dNt), \dNi
    (or \diN), without causing confusion with existing command (e.g., \dn)
    * While capitalization of N might seem arbitrary, it can be acceptable
    as it's "negating" some concept
    
    
    About other suggestions:
    
    * While "a" (adult) and "e" (elders) are adorable, they introduce new
    terminologies that are not widely known to the Postgres community. Being
    super pedantic, an adult is always a child of some parent, and an elder
    must always have one or more children. In addition, \da and \det already
    exists.
    
    * Using \pset: As Tom said, plus I think explicit is better than
    implicit. Consider some DBA (or their colleague) adding this \pset into
    .psqlrc, and then forget about it.
    
    * Using \dP 0: The command \dP is already used to show partitioned
    tables, and the default behavior (i.e., not \dPn) is to only show the
    roots of the partition. What I'd like is to show roots as well as
    non-partitioned tables.
    
    If there are no hard objections, I'll proceed with adding the N letter
    to \d commands.
    
    Best Regards,
    Sadeq Dousti
    
  13. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Greg Sabino Mullane <htamfids@gmail.com> — 2025-02-24T13:46:32Z

    On Mon, Feb 24, 2025 at 3:07 AM Sadeq Dousti <msdousti@gmail.com> wrote:
    
    > * While capitalization of N might seem arbitrary, it can be acceptable as
    > it's "negating" some concept
    > ...
    >
    
    
    > If there are no hard objections, I'll proceed with adding the N letter to
    > \d commands.
    >
    
    Not strongly opposed, but "N" is a slightly odd as we already have "n" and
    pg_dump uses both "n" and "N", where the latter is the inverse of the
    former. But since I have no better idea at the moment, a weak +1 until more
    bike shedders arrive. :)
    
    Cheers,
    Greg
    
    P.S. On reflection, I do like having a capital letter more than a lowercase
    for an exclusion case like this.
    
    --
    Crunchy Data - https://www.crunchydata.com
    Enterprise Postgres Software Products & Tech Support
    
  14. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-25T23:28:47Z

    Thanks Greg and others for the feedback!
    
    Please find attached the patch for implementing \dN (including \dNt, \dNi,
    \dNit).
    
    Best Regards,
    Sadeq Dousti
    
  15. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Greg Sabino Mullane <htamfids@gmail.com> — 2025-02-26T00:00:57Z

    The patch applies cleanly, and works as advertised. Nice work!
    
    Quick notes:
    
    * doc/src/sgml/ref/psql-ref.sgml
    
    In the varlistentry section, the order should be the same as the other
    places (N after m)
    
    Line 1644 has an extra comma
    
    Line 1651, maybe the example is simpler as \dNt to keep the wording better,
    because "indexes that are not partitions" looks odd.
    
    These bits:
    
      pg_log_error("Did not find any%s relations named \"%s\".",
        no_partition_description, pattern);
    
    are not good for translation. We want things simple with replaceable
    args/constants, but not replaceable words.
    
    I think the myopt.title ones are fine.
    
    * bin/psql/help.c:
    
    \\dN[Sx+] [PATTERN]     list relation, table, index (no partitions)
    
    better as:
    
    \\dN[Sx+] [PATTERN]     list tables and indexes (no partitions)
    
    Cheers,
    Greg
    
    --
    Crunchy Data - https://www.crunchydata.com
    Enterprise Postgres Software Products & Tech Support
    
  16. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-26T00:27:23Z

    Dear Greg,
    
    Thank you so much for the kind and prompt review!
    
    Please find the patches attached. The second patch (0002) is where I
    applied the requested changes.
    
    Best regards,
    Sadeq Dousti
    
    
    On Wed, Feb 26, 2025 at 1:01 AM Greg Sabino Mullane <htamfids@gmail.com>
    wrote:
    
    > The patch applies cleanly, and works as advertised. Nice work!
    >
    > Quick notes:
    >
    > * doc/src/sgml/ref/psql-ref.sgml
    >
    > In the varlistentry section, the order should be the same as the other
    > places (N after m)
    >
    > Line 1644 has an extra comma
    >
    > Line 1651, maybe the example is simpler as \dNt to keep the wording
    > better, because "indexes that are not partitions" looks odd.
    >
    > These bits:
    >
    >   pg_log_error("Did not find any%s relations named \"%s\".",
    >     no_partition_description, pattern);
    >
    > are not good for translation. We want things simple with replaceable
    > args/constants, but not replaceable words.
    >
    > I think the myopt.title ones are fine.
    >
    > * bin/psql/help.c:
    >
    > \\dN[Sx+] [PATTERN]     list relation, table, index (no partitions)
    >
    > better as:
    >
    > \\dN[Sx+] [PATTERN]     list tables and indexes (no partitions)
    >
    > Cheers,
    > Greg
    >
    > --
    > Crunchy Data - https://www.crunchydata.com
    > Enterprise Postgres Software Products & Tech Support
    >
    >
    
  17. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Greg Sabino Mullane <htamfids@gmail.com> — 2025-02-26T15:01:14Z

    Changes look good to me, thanks. Can you make a new patch that applies a
    single set of changes to HEAD?
    
    Cheers,
    Greg
    
    --
    Crunchy Data - https://www.crunchydata.com
    Enterprise Postgres Software Products & Tech Support
    
  18. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-26T17:50:45Z

    Thanks a lot Greg!
    
    > Changes look good to me, thanks. Can you make a new patch that applies a
    single set of changes to HEAD?
    
    Please find attached the diff to Head in a single file.
    
    Best Regards,
    Sadeq Dousti
    
  19. Re: psql \dh: List High-Level (Root) Tables and Indexes

    vignesh C <vignesh21@gmail.com> — 2025-02-27T05:43:59Z

    On Wed, 26 Feb 2025 at 23:21, Sadeq Dousti <msdousti@gmail.com> wrote:
    >
    > Thanks a lot Greg!
    >
    > > Changes look good to me, thanks. Can you make a new patch that applies a single set of changes to HEAD?
    >
    > Please find attached the diff to Head in a single file.
    
    Currently we are supporting only PG13 and higher versions. I'm not
    sure if we should support lesser than PG15 version:
    +       /*
    +        * Note: Declarative table partitioning is only supported as of Pg 10.0.
    +        */
    +       if (showNoPartitions && pset.sversion < 100000)
    +       {
    +               char            sverbuf[32];
    +
    +               pg_log_error("The server (version %s) does not support
    declarative table partitioning.",
    +
    formatPGVersionNumber(pset.sversion, false,
    +
                sverbuf, sizeof(sverbuf)));
    +               return true;
    +       }
    
    Regards,
    Vignesh
    
    
    
    
  20. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-02-27T11:44:46Z

    Thanks Vignesh for the review!
    
    
    > Currently we are supporting only PG13 and higher versions.
    
    I understand that servers older than PG13 are no longer supported. But on
    the client side, we still have this notice at the top of describe.c file,
    which indicates that the client should support 9.2+.
    
    * Support for the various \d ("describe") commands.  Note that the current
     * expectation is that all functions in this file will succeed when working
     * with servers of versions 9.2 and up.  It's okay to omit irrelevant
     * information for an old server, but not to fail outright.  (But failing
     * against a pre-9.2 server is allowed.)
    
    I'm just following the instructions here so as not to break anything
    unwanted, and you can see for instance \dP is doing the same.
    
    That said, I'm totally fine with removing the "if" from my patch, but first
    I think a committer should update the above comment to the least supported
    version for client code.
    
    Best Regards,
    Sadeq Dousti
    
  21. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Greg Sabino Mullane <htamfids@gmail.com> — 2025-03-27T15:08:06Z

    I think it's fine the way it is, with regards to v10 check. Can you post a
    rebased patch?
    
    Cheers,
    Greg
    
    --
    Crunchy Data - https://www.crunchydata.com
    Enterprise Postgres Software Products & Tech Support
    
  22. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Christoph Berg <myon@debian.org> — 2025-03-27T15:19:55Z

    Re: Sadeq Dousti
    > Thanks Greg and others for the feedback!
    > 
    > Please find attached the patch for implementing \dN (including \dNt, \dNi,
    > \dNit).
    
    I don't care particularly about the choice of letter, but I think this
    is the wrong way round. It should be \dtN instead of \dNt.
    
    Is the form \dN actually useful? For partitioned tables, you'd only
    get the empty root indexes. If you actually wanted that, there's still
    \dtiN.
    
    Christoph
    
    
    
    
  23. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-03-27T22:48:23Z

    > I think it's fine the way it is, with regards to v10 check. Can you post a
    > rebased patch?
    >
    
    Hi Greg,
    I just checked here: https://commitfest.postgresql.org/patch/5594/
    Seems the patch is OK with the latest master, and no rebase is needed.
    
    Do you mean that instead of a diff, I post a patch?
    
    Best regards,
    Sadeq
    
  24. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-03-27T23:13:07Z

    > I think this is the wrong way round.
    > It should be \dtN instead of \dNt.
    
    Hi Christoph,
    The order does not matter, the user can use \dNt or \dtN, as they do
    exactly the same thing. Letters coming after \d can be freely permuted. If
    you mean a change to the documentation or tests, I can apply whatever order
    makes more sense, as I don't have any particular preference.
    
    > Is the form \dN actually useful?
    It's a shortcut for \dtiN. Similarly, \d is a shortcut for \dtvmsE. I'd
    like to keep a default because otherwise, we should err if the user types
    \dN without further qualifying it, and combining N with other letters (s,
    m, E, v, ...) while not including t & i would also result in error.
    
    > For partitioned tables, you'd only get the empty root indexes.
    Your statement is correct, but bear with me to give the full version.
    With \dN, you get all the tables and indexes that are not partitions.
    * root tables
    * non-partitioned tables
    * indexes on root tables
    * indexes on non-partitioned tables
    For me, this is the top-level table and index structure in a database. It
    can be further restricted by adding t (\dNt or \dtN) to limit it to tables,
    and adding i (\dNi or \diN) to limit it to indexes.
    
    Of course, other combinations like \dNvs are also supported.
    
    Best regards,
    Sadeq
    
  25. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-03-27T23:28:50Z

    Sorry Greg,
    
    Just understood what you mean. Please find attached the v6 of the patch.
    
    Best regards,
    Sadeq
    
  26. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Christoph Berg <myon@debian.org> — 2025-03-28T10:27:20Z

    Re: Sadeq Dousti
    > > I think this is the wrong way round.
    > > It should be \dtN instead of \dNt.
    > 
    > Hi Christoph,
    > The order does not matter, the user can use \dNt or \dtN, as they do
    > exactly the same thing. Letters coming after \d can be freely permuted. If
    > you mean a change to the documentation or tests, I can apply whatever order
    > makes more sense, as I don't have any particular preference.
    
    Oh ok, that's perfect then.
    
            HELP0("  \\dn[Sx+] [PATTERN]     list schemas\n");
    +       HELP0("  \\dN[Sx+] [PATTERN]     list tables and indexes (no partitions)\n");
            HELP0("  \\do[Sx+] [OPPTRN [TYPEPTRN [TYPEPTRN]]]\n"
    
    Is this really a new "top-level" \d command and not a flag for the
    existing \d commands? I would think that the help texts should place
    the N next to S which is a similar "show different set of things"
    modifier:
    
    \d[NSx+]                list tables, views, and sequences
    \di[NSx+] [PATTERN]     list indexes
    \dt[NSx+] [PATTERN]     list tables
    
    For documentation and tests, the N should be at the end like S is at
    the end in \dt[S+].
    
    Christoph
    
    
    
    
  27. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-03-28T11:55:22Z

    The S flag is "universal" enough and can be combined with a wide variety of
    commands to show system views. Examples include \d, \dn, \dp, \dL, and so
    on. In contrast, the N I'm introducing can only be combined with \d, so I
    wouldn't treat it the same as S.
    
    All things that combine with \d (t, i, m, s, etc.) are used to show an
    object type. In that sense, they are also flags, but the generic nature of
    S and x flags made them stand out in the documentation.
    
    Best regards,
    Sadeq
    
    On Fri, Mar 28, 2025, 11:27 Christoph Berg <myon@debian.org> wrote:
    
    > Re: Sadeq Dousti
    > > > I think this is the wrong way round.
    > > > It should be \dtN instead of \dNt.
    > >
    > > Hi Christoph,
    > > The order does not matter, the user can use \dNt or \dtN, as they do
    > > exactly the same thing. Letters coming after \d can be freely permuted.
    > If
    > > you mean a change to the documentation or tests, I can apply whatever
    > order
    > > makes more sense, as I don't have any particular preference.
    >
    > Oh ok, that's perfect then.
    >
    >         HELP0("  \\dn[Sx+] [PATTERN]     list schemas\n");
    > +       HELP0("  \\dN[Sx+] [PATTERN]     list tables and indexes (no
    > partitions)\n");
    >         HELP0("  \\do[Sx+] [OPPTRN [TYPEPTRN [TYPEPTRN]]]\n"
    >
    > Is this really a new "top-level" \d command and not a flag for the
    > existing \d commands? I would think that the help texts should place
    > the N next to S which is a similar "show different set of things"
    > modifier:
    >
    > \d[NSx+]                list tables, views, and sequences
    > \di[NSx+] [PATTERN]     list indexes
    > \dt[NSx+] [PATTERN]     list tables
    >
    > For documentation and tests, the N should be at the end like S is at
    > the end in \dt[S+].
    >
    > Christoph
    >
    
  28. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-07-27T23:15:44Z

    Dear Matt,
    
    Thanks a lot for the nice suggestion. Please find attached the version 7 of
    the patch, which incorporates your suggestion: It now disregards the N in
    \dN[ti] if pset.sversion < 100000.
    
    Best Regards,
    Sadeq
    
    PS: Received an error from the mailer, with the following error message, so
    removed the mentioned email and resending the email. Sorry if you receive
    it twice.
    
    This email has been blocked from posting to the lists,
    and for this reason your email has not been delivered to
    the list. If you wish to post to the list, please remove
    dwehttam@gmail.com from the address fields of your email,
    and try again.
    
    
    
    On Fri, Jun 20, 2025 at 10:16 PM Matt Dailis <dwehttam@gmail.com> wrote:
    
    > Hi Sadeq,
    >
    > > * Support for the various \d ("describe") commands.  Note that the
    > current
    > >  * expectation is that all functions in this file will succeed when
    > working
    > >  * with servers of versions 9.2 and up.  It's okay to omit irrelevant
    > >  * information for an old server, but not to fail outright.  (But failing
    > >  * against a pre-9.2 server is allowed.)
    > >
    > > I'm just following the instructions here so as not to break anything
    > unwanted, and you can see for instance \dP is doing the same.
    >
    > One possible interpretation of this comment is that a command should
    > try to return as much relevant information as it reasonably can for an
    > older postgres version. The patch currently treats \dtiN as an error
    > for pset.sversion < 100000. What do you think about making \dtiN
    > behaving identically to \dti on older postgres versions? We know that
    > the older database definitely has no partitions, and the user is
    > telling us that they'd like to see everything except for the
    > partitions, so it seems reasonable to me to ignore the N option in
    > that case.
    >
    > Best,
    > Matt Dailis
    >
    
  29. Re: psql \dh: List High-Level (Root) Tables and Indexes

    Sadeq Dousti <msdousti@gmail.com> — 2025-12-14T21:05:21Z

    Hi all,
    
    Please find attached version 8 of the patch. Two changes:
    * Rebased on the latest master
    * Improved commit message
    
    Best regards,
    Sadeq Dousti