From: Hemapriya <priyam_1121@yahoo.com>
To: pgsql-admin@postgresql.org
Subject: Query with Max, Order by is very slow.......
Date: Wed, 7 Apr 2004 14:03:54 -0700 (PDT)
Message-ID: <20040407210354.79531.qmail@web21322.mail.yahoo.com> (raw)
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: priyam_1121@yahoo.com
Subject: Re: Query with Max, Order by is very slow.......
In-Reply-To: <20040407210354.79531.qmail@web21322.mail.yahoo.com>
References: <20040407210354.79531.qmail@web21322.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox