query optimization Anyone know a better way to run this query

From: "David Blood" <david(at)matraex(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: query optimization Anyone know a better way to run this query
Date: 2002-02-20 23:08:27
Message-ID: 004b01c1ba63$815ba4c0$0100a8c0@david2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Anyone know a better way to run this query to make it faster.
It is running on a a dual 800 pIII with 1gig ram.



SET ENABLE_SEQSCAN TO OFF;
Explain
select
(loginFName|| ' ' || loginLName) as Name,
loginID as PFLID,
count(1) as NumberOfLeads
from
tbllogin,
tblcold
where
coldsponsorid = tbllogin.loginid
group by
loginID,
loginFName,
LoginLName
order by
name
limit
0

QUERY PLAN:
Limit (cost=1453435.17..1453435.17 rows=1 width=32)
-> Sort (cost=1453435.17..1453435.17 rows=242562 width=32)
-> Aggregate (cost=1407484.24..1431740.44 rows=242562 width=32)
-> Group (cost=1407484.24..1425676.39 rows=2425620
width=32)
-> Sort (cost=1407484.24..1407484.24 rows=2425620
width=32)
-> Merge Join (cost=0.00..1070338.18
rows=2425620 width=32)
-> Index Scan using tbllogin_pkey on
tbllogin (cost=0.00..465.90 rows=2658 width=28)
-> Index Scan using spons_tblcold_index
on tblcold (cost=0.00..1039518.81 rows=2425620 width=4)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-20 23:18:13 Re: [GENERAL] schema error upgrading from 7.1 to 7.2
Previous Message Nikheel Dhekne 2002-02-20 23:01:44 returning rows from a function