Querying database for table pk - better way?

Поиск
Список
Период
Сортировка
От Josh Trutwin
Тема Querying database for table pk - better way?
Дата
Msg-id 20070905161722.7e83494d@sinkhole.intrcomm.net
обсуждение исходный текст
Ответы Re: Querying database for table pk - better way?  ("Rodrigo De León" <rdeleonp@gmail.com>)
Re: Querying database for table pk - better way?  ("Merlin Moncure" <mmoncure@gmail.com>)
Список pgsql-general
I have a php application that needs to query the PK of a table - I'm
currently using this from the information_schema views:

SELECT column_name
  FROM information_schema.table_constraints tc
 INNER JOIN information_schema.constraint_column_usage ccu
       ON tc.constraint_name = ccu.constraint_name
   AND tc.constraint_schema = ccu.constraint_schema
 WHERE constraint_type = 'PRIMARY KEY'
   AND tc.table_name = '$table'
   AND tc.table_schema = '$schema'

This is an extremely slow query tho.

The top/bottom of my EXPLAIN ANALYZE (8.1.9):

Nested Loop  (cost=22.20..342.24 rows=1 width=64) (actual
time=68985.008..68988.784 rows=1 loops=1)
   Join Filter: ("inner".oid = "outer".relnamespace)
   ->  Nested Loop (cost=22.20..341.15 rows=1 width=68) (actual
time=68984.922..68988.694 rows=1 loops=1)

<snip about 60 rows>

Total runtime: 68989.637 ms

I can put the full explain output on the web if it's useful.

Curious if there is a better/cheaper way to get the data I'm looking
for though?

Thanks,

Josh

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

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: psql hanging
Следующее
От: "Rodrigo De León"
Дата:
Сообщение: Re: Querying database for table pk - better way?