Re: SQL Property Graph Queries (SQL/PGQ)

Поиск
Список
Период
Сортировка
От Henson Choi
Тема Re: SQL Property Graph Queries (SQL/PGQ)
Дата
Msg-id CAAAe_zAwH9vcc7uoc+W81pLxihETNO9nrZTEWzCCHTrDCf9RJw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: SQL Property Graph Queries (SQL/PGQ)  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Список pgsql-hackers
Hi Ashutosh,

Thank you for the detailed review and feedback.

2025년 12월 30일 (화) PM 6:50, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>님이 작성:
Hi Henson,

Thanks a lot for your interest in SQL/PGQ patches. Your expertise will
certainly help.


I appreciate the opportunity to contribute.
 
On Fri, Dec 26, 2025 at 6:03 PM Henson Choi <assam258@gmail.com> wrote:
>
> Following up on my Dec 24 email - three features completed:
>
> 1. LABELS() function
>    - Returns text[] of element labels
>    - Fixed privilege checking from previous version
>    - Enables optimizer pushdown for branch pruning
>
> 2. PROPERTY_NAMES() function
>    - Returns text[] of property names
>    - Similar approach to LABELS()
>

I could not find specification of these functions in SQL/PGQ standard.
It's a large document and I might be missing something. Can you please
point me to the relevant sections?


You're correct - LABELS() and PROPERTY_NAMES() are not in the SQL/PGQ
standard. I was inspired by similar functions in Cypher (labels(), keys())
and Oracle's PGQL (which has LABELS(), though Oracle is moving toward
SQL/PGQ compliance as well).

The attached code demonstrates that through query rewrite, these functions
can enable planner-level table pruning optimizations. This becomes
particularly valuable for client applications - GUI tools could use label
names as host variables for flexible label-based filtering, and
PROPERTY_NAMES() (similar to Cypher's keys()) would enable dynamic property
inspection for display or selective querying of elements with specific
properties.

While there's a distinction between structured (SQL/PGQ) and semi-structured
(Cypher) query models, I don't think we need to strictly exclude
semi-structured patterns that work well within the structured framework.
Whether this should be proposed as a future SQL/PGQ standard extension or
remain a PostgreSQL-specific extension is worth discussion. Given the
practical utility demonstrated in graph query deployments, there might be
value in standardizing such introspection functions.

Similarly, I'd suggest considering Cypher's SHORTEST PATH for future
SQL/PGQ standards. If we treat SHORTEST PATH as a specialized join type
in SQL and handle it through query rewrite, PostgreSQL's existing planner
infrastructure could support it efficiently. This approach has been proven
in practice and could be a valuable addition to the next standard revision.
 
> 3. Multiple path patterns
>    - Syntax: MATCH (a)->(b), (b)->(c)
>    - Implements SQL/PGQ standard feature (was TODO)
>

This path pattern list feature is discussed in section 10.4 of the
standard. I think supporting this feature would be a good addition to
SQL/PGQ compliance. The current patchset is already large. I (and
AFAIK Peter as well) am focusing on getting that patchset in a
committable shape. Once committed, it will facilitate adding features
like path pattern list, quantified path patterns, label conjunction
etc. as incremental relatively smaller commits.


Understood. I fully support getting the core patchset committed first.
 
Since you could build one of the complex features without changing a
lot of earlier implementation, it validates that the basic
implementation is extensible and yet robust. Thanks for that
validation.


That was my finding as well - the architecture is well-designed for
extensibility.
 
The way you have implemented it, it can lead to a path pattern with
two vertex patterns next to each other without an interleaving edge
pattern. That would throw an error or assertion. If you try path
patterns without a common vertex, you will get that error. That is not
covered by your tests. In such cases, the paths should end up being
full-joined rather than concatenated. I don't see it being implemented
that way. I think more work is needed here.

You're absolutely right, and I apologize for the hasty implementation.

I agree that merging this after the current commitfest makes more sense -
it keeps the core patchset focused and reviewable. I'll rework this
properly with correct handling for disjoint patterns and full join logic.

Having more people who can maintain and extend SQL/PGQ reduces the
risk for both the community and PostgreSQL itself. When I have a revised
version ready, would you be willing to review it again?


[1] https://www.postgresql.org/message-id/CAExHW5sr+dJPCFw2OqXUfPPqPks8qmsivaAYhRiBdFANcX8RHw@mail.gmail.com

--
Best Wishes,
Ashutosh Bapat

Best regards,
Henson 

В списке pgsql-hackers по дате отправления: