From: | Hemapriya <priyam_1121(at)yahoo(dot)com> |
---|---|
To: | pgsql-admin(at)postgresql(dot)org |
Subject: | Query with Max, Order by is very slow....... |
Date: | 2004-04-07 21:03:54 |
Message-ID: | 20040407210354.79531.qmail@web21322.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2004-04-07 21:11:20 | [admin] index in pk |
Previous Message | Tom Lane | 2004-04-07 20:56:53 | Re: Out of space |