Query with Max, Order by is very slow.......

Поиск
Список
Период
Сортировка
От Hemapriya
Тема Query with Max, Order by is very slow.......
Дата
Msg-id 20040407210354.79531.qmail@web21322.mail.yahoo.com
обсуждение исходный текст
Ответы Re: Query with Max, Order by is very slow.......  (Sam Barnett-Cormack <s.barnett-cormack@lancaster.ac.uk>)
Re: Query with Max, Order by is very slow.......  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-admin
Hi,

we have table having 23 million rows.
This is the table structure.
Table Request:

  Column   |            Type             | Modifiers
-----------+-----------------------------+-----------
 origindb  | character(1)                | not null
 uid       | integer                     | not null
 rtype     | integer                     |
 senderid  | integer                     |
 destaddr  | character varying(15)       |
 opid      | integer                     |
 devmodel  | integer                     |
 ikind     | integer                     |
 itemid    | character varying(10)       |
 tranfk    | integer                     |
 enteredon | timestamp without time zone |
 status    | integer                     |
 accountid | integer                     |
Indexes:
    "request_pkey" primary key, btree (origindb, uid)

I do max Query like this

select max(uid) from request where originDB=1;

it took around 20 min to return the result..  Since
max, count functions do the full table scan, i tried
the workaround given..

select uid from request where originDB=1 order by uid
desc limit 1;

this query runs forever.. i tried even without where
condition..no result..

I'm not able to figure out what could be the reason..
can anybody help?

Thanks in Advance

Regards
Priya


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Out of space
Следующее
От: "Jaime Casanova"
Дата:
Сообщение: [admin] index in pk