Re: PKs without indexes

Поиск
Список
Период
Сортировка
От Jerry Sievers
Тема Re: PKs without indexes
Дата
Msg-id 8762qap8u2.fsf@comcast.net
обсуждение исходный текст
Ответ на PKs without indexes  (John P Weatherman <jweatherman91@alumni.wfu.edu>)
Ответы Re: PKs without indexes
Список pgsql-admin
John P Weatherman <jweatherman91@alumni.wfu.edu> writes:

> Hi all,
>
> I am attempting to set up slony-i and have run into a minor
> glitch...apparently whoever designed the database I have inherited
> didn't consistently build indexes to go along with Primary Keys, or at
> least that's the error message I have been getting.  I am far from
> confident in my own sqlfu in the catalog tables.  Does anyone have a
> script for identifying tables without indexes that correspond to their
> PKs?  I'm just trying to avoid re-inventing the wheel if I can help it.

Here's an example for you...

begin;

create schema foo;
set search_path to foo;

create table haspk (a int primary key);
create table missingpk (a int);

select relname
from pg_class c
join pg_namespace n on c.relnamespace = n.oid
where nspname = 'foo'
and relkind = 'r'
and c.oid not in (
    select conrelid
    from pg_constraint
    where contype = 'p'
);

abort;

HTH
>
> Thanks,
>
> John
>
>
> John P Weatherman
> Sr Database Administrator
> Centerstone

--
Jerry Sievers
Postgres DBA/Development Consulting
e: gsievers19@comcast.net
p: 305.321.1144

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PKs without indexes
Следующее
От: rudi
Дата:
Сообщение: Re: Streaming replication: rsync to switchover