pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Koshino Taiki <koshino@sraoss.co.jp>
To: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: doc: Reformat SELECT queries using GRAPH_TABLE
Date: Tue, 25 Aug 2026 01:33:22 +0000
Message-ID: <OS9P286MB64861F8B663553D3E18F368494AF2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CAExHW5uAtipTuUhZk7g5uaJQc4+X50_YptiAzfr4nOsmDDifaA@mail.gmail.com>
References: <OS9P286MB64860BD6CD6D4B4B0E1CEDE894A32@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM>
	<CAExHW5uAtipTuUhZk7g5uaJQc4+X50_YptiAzfr4nOsmDDifaA@mail.gmail.com>

>  I agree that spreading this query over multiple lines would be better
>  but the way it's done in the patch doesn't feel right. It leaves the
>  first vertex pattern on the original line along with GRAPH_TABLE and
>  MATCH. The rest of the path pattern is moved to the next line. This
>  make it hard to grasp the whole path pattern in one go. I think we
>  should try leaving GRAPH_TABLE ( ... on the original line and move the
>  whole MATCH clause to the next line and COLUMNS to another line.
>  However the path pattern would still be long enough that it would
>  require scrolling. But we should try that first.
>
>  If we break the path pattern into multiple lines, the problem there is
>  whether to keep the arrows or connecting lines along with the vertex
>  or with the edge. Since the standard defines an edge pattern as the
>  arrow/connector along with the brackets, it might be better to keep
>  the arrows and connectors with the edge pattern. Formatting the query
>  as below might be better.
>
>  SELECT customer_name FROM GRAPH_TABLE (myshop
>
>             MATCH (c IS customers)
>
>                           -[IS customer_orders]->
>
>                           (o IS orders WHERE o.ordered_when =
>  current_date)
>
>             COLUMNS (c.name AS customer_name));
>
>  But with that one has to read multiple lines to understand the path
>  pattern. So I would avoid it for a small pattern like this.

Hi,

Thanks for the detailed feedback.
I put together a v2 patch that follows the approach you suggested:
keeping GRAPH_TABLE ( on the opening line, moving the whole MATCH
clause to its own line, and putting COLUMNS on another line, for example:

SELECT customer_name FROM GRAPH_TABLE (myshop
    MATCH (c IS customers)
        -[IS customer_orders]->
        (o IS orders WHERE o.ordered_when = current_date)
    COLUMNS (c.name AS customer_name));

I've confirmed that with this formatting,
each line stays short enough that
horizontal scrolling is unlikely to be needed,
while the path pattern is still easy to read as a whole.

I applied the same formatting consistently to both occurrences
in ddl.sgml and the one in queries.sgml. Attached is the v2 patch.
Let me know if this matches what you had in mind,
or if you would prefer a different line break for the path pattern.

Regards,
Taiki Koshino

Taiki Koshino<koshino@sraoss.co.jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/


________________________________


On Fri, Aug 21, 2026 at 12:35 PM Koshino Taiki <koshino@sraoss.co.jp> wrote:
>
> Hi,
>
> The SELECT queries using GRAPH_TABLE in ddl.sgml and queries.sgml
> were written on single long lines, requiring horizontal scrolling.
>
> This patch breaks the queries across multiple lines to improve
> readability.  This is also consistent with the CREATE PROPERTY GRAPH
> statement in the PostgreSQL documentation, which is already formatted
> across multiple lines:

I agree that spreading this query over multiple lines would be better
but the way it's done in the patch doesn't feel right. It leaves the
first vertex pattern on the original line along with GRAPH_TABLE and
MATCH. The rest of the path pattern is moved to the next line. This
make it hard to grasp the whole path pattern in one go. I think we
should try leaving GRAPH_TABLE ( ... on the original line and move the
whole MATCH clause to the next line and COLUMNS to another line.
However the path pattern would still be long enough that it would
require scrolling. But we should try that first.

If we break the path pattern into multiple lines, the problem there is
whether to keep the arrows or connecting lines along with the vertex
or with the edge. Since the standard defines an edge pattern as the
arrow/connector along with the brackets, it might be better to keep
the arrows and connectors with the edge pattern. Formatting the query
as below might be better.

SELECT customer_name FROM GRAPH_TABLE (myshop

           MATCH (c IS customers)

                         -[IS customer_orders]->

                         (o IS orders WHERE o.ordered_when =
current_date)

           COLUMNS (c.name AS customer_name));

But with that one has to read multiple lines to understand the path
pattern. So I would avoid it for a small pattern like this.

--
Best Wishes,
Ashutosh Bapat


Attachments:

v2-0001-doc-Reformat-SELECT-queries-using-GRAPH_TABLE.patch (application/octet-stream, 2.8K) download From 8164ca17f7f53a363787c79370a28c455037f3f2 Mon Sep 17 00:00:00 2001 From: Taiki Koshino <koshio@sraoss.co.jp> Date: Thu, 20 Aug 2026 10:52:17 +0900 Subject: [PATCH v2] doc: Reformat SELECT queries using GRAPH_TABLE The SELECT queries using GRAPH_TABLE in ddl.sgml and queries.sgml were written on single long lines, requiring horizontal scrolling. Break the queries across multiple lines to improve readability. --- doc/src/sgml/ddl.sgml | 12 ++++++++++-- doc/src/sgml/queries.sgml | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index 160f4eebb35..1ca5027d57f 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -5824,7 +5824,11 @@ CREATE PROPERTY GRAPH myshop This graph could then be queried like this: <programlisting> -- get list of customers active today -SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name)); +SELECT customer_name FROM GRAPH_TABLE (myshop + MATCH (c IS customers) + -[IS customer_orders]-> + (o IS orders WHERE o.ordered_when = current_date) + COLUMNS (c.name AS customer_name)); </programlisting> corresponding approximately to this relational query: <programlisting> @@ -5888,7 +5892,11 @@ CREATE PROPERTY GRAPH myshop <para> With this definition, we can write a query like this: <programlisting> -SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customer)-[IS has_placed]->(o IS "order" WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name)); +SELECT customer_name FROM GRAPH_TABLE (myshop + MATCH (c IS customer) + -[IS has_placed]-> + (o IS "order" WHERE o.ordered_when = current_date) + COLUMNS (c.name AS customer_name)); </programlisting> With the new labels the <literal>MATCH</literal> clause is now more intuitive. </para> diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml index 3d729f983b5..44ec44df83c 100644 --- a/doc/src/sgml/queries.sgml +++ b/doc/src/sgml/queries.sgml @@ -2768,7 +2768,11 @@ SELECT * FROM t; Consider this example from <xref linkend="ddl-property-graphs"/>: <programlisting> -- get list of customers active today -SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name)); +SELECT customer_name FROM GRAPH_TABLE (myshop + MATCH (c IS customers) + -[IS customer_orders]-> + (o IS orders WHERE o.ordered_when = current_date) + COLUMNS (c.name AS customer_name)); </programlisting> The graph query part happens inside the <literal>GRAPH_TABLE</literal> construct. As far as the rest of the query is concerned, this acts like a -- 2.52.0

view thread (8+ messages)  latest in thread

Message-ID: <OS9P286MB64861F8B663553D3E18F368494AF2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM>
Permalink:  ../OS9P286MB64861F8B663553D3E18F368494AF2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/OS9P286MB64861F8B663553D3E18F368494AF2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: koshino@sraoss.co.jp, ashutosh.bapat.oss@gmail.com
  Subject: Re: doc: Reformat SELECT queries using GRAPH_TABLE
  In-Reply-To: <OS9P286MB64861F8B663553D3E18F368494AF2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM>
  References: <OS9P286MB64860BD6CD6D4B4B0E1CEDE894A32@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM> <CAExHW5uAtipTuUhZk7g5uaJQc4+X50_YptiAzfr4nOsmDDifaA@mail.gmail.com> <OS9P286MB64861F8B663553D3E18F368494AF2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox