GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.postgresql.org — F.19. intagg November 19, 2026: PostgreSQL 19 Released!
Development Versions:
devel
F.19. intaggThe F.19.1. FunctionsThe aggregator is an aggregate function The enumerator is a function F.19.2. Sample UsesMany database systems have the notion of a one to many table. Such a table usually sits between two indexed tables, for example: CREATE TABLE left (id INT PRIMARY KEY, ...); CREATE TABLE right (id INT PRIMARY KEY, ...); CREATE TABLE one_to_many(left INT REFERENCES left, right INT REFERENCES right); It is typically used like this: SELECT right.* from right JOIN one_to_many ON (right.id = one_to_many.right)
WHERE one_to_many.left =
This will return all the items in the right hand table for an entry in the left hand table. This is a very common construct in SQL. Now, this methodology can be cumbersome with a very large number of entries in the CREATE TABLE summary AS SELECT left, int_array_aggregate(right) AS right FROM one_to_many GROUP BY left; This will create a table with one row per left item, and an array of right items. Now this is pretty useless without some way of using the array; that's why there is an array enumerator. You can do SELECT left, int_array_enum(right) FROM summary WHERE left =
The above query using SELECT left, right FROM one_to_many WHERE left =
The difference is that the query against the summary table has to get only one row from the table, whereas the direct query against On one system, an SELECT right, count(right) FROM
( SELECT left, int_array_enum(right) AS right
FROM summary JOIN (SELECT left FROM left_table WHERE left =
Submit correctionIf you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |