Re: Finding referecing and referenced tables, adaptation from David Fetter's solution

Поиск
Список
Период
Сортировка
От Gavin Flower
Тема Re: Finding referecing and referenced tables, adaptation from David Fetter's solution
Дата
Msg-id 4E33EFBE.2070409@archidevsys.co.nz
обсуждение исходный текст
Ответ на Finding referecing and referenced tables, adaptation from David Fetter's solution  (bricklen <bricklen@gmail.com>)
Ответы Re: Finding referecing and referenced tables, adaptation from David Fetter's solution  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список pgsql-general
On 30/07/11 10:45, bricklen wrote:
> [...]
> CREATE OR REPLACE VIEW table_dependencies AS (
> WITH RECURSIVE t AS (
>      SELECT
>          c.oid AS origin_id,
>          c.oid::regclass::text AS origin_table,
>          c.oid AS referencing_id,
>          c.oid::regclass::text AS referencing_table,
>          c2.oid AS referenced_id,
>          c2.oid::regclass::text AS referenced_table,
>          ARRAY[c.oid::regclass,c2.oid::regclass] AS chain
>      FROM pg_catalog.pg_constraint AS co
>      INNER JOIN pg_catalog.pg_class AS c
>      ON c.oid = co.conrelid
>      INNER JOIN pg_catalog.pg_class AS c2
>      ON c2.oid = co.confrelid
> [...]
I am curious about the explicit use of INNER JOINs, I find them
cumbersome, so I rewrote the code to remove them, I know in some
situations that they can improve performance - but was this the case
here, or is there some other subtlety that I have missed?
[...]
   SELECT
         c1.oid::regclass::text  AS origin_table,
         c2.oid                  AS referenced_id,
         c2.oid::regclass::text  AS referenced_table,
         ARRAY[c1.oid::regclass,c2.oid::regclass] AS chain
     FROM
         pg_catalog.pg_constraint    AS co,
         pg_catalog.pg_class         AS c1,
         pg_catalog.pg_class         AS c2
     WHERE
         c1.oid = co.conrelid AND
         c2.oid = co.confrelid
[...]

Cheers,
Gavin

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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: List Functions and Code
Следующее
От: Gavin Flower
Дата:
Сообщение: Re: Finding referecing and referenced tables, adaptation from David Fetter's solution