X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ECC1052802 for ; Thu, 30 Jun 2005 19:43:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40673-10 for ; Thu, 30 Jun 2005 22:43:35 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D839052A17 for ; Thu, 30 Jun 2005 19:43:32 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j5UMhY78022504; Thu, 30 Jun 2005 18:43:34 -0400 (EDT) To: John Mendenhall Cc: pgsql-performance@postgresql.org Subject: Re: ported application having performance issues In-reply-to: <20050630222451.GA17628@calvin.surfutopia.net> References: <20050630222451.GA17628@calvin.surfutopia.net> Comments: In-reply-to John Mendenhall message dated "Thu, 30 Jun 2005 15:24:51 -0700" Date: Thu, 30 Jun 2005 18:43:34 -0400 Message-ID: <22503.1120171414@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/603 X-Sequence-Number: 13240 John Mendenhall writes: > Merge Join (cost=4272.84..4520.82 rows=1230 width=21) (actual time=3998.771..4603.739 rows=699 loops=1) > Merge Cond: ("outer".contact_id = "inner".id) > -> Index Scan using lead_requests_contact_id_idx on lead_requests lr (cost=0.00..74.09 rows=1435 width=21) (actual time=0.070..22.431 rows=1430 loops=1) > -> Sort (cost=4272.84..4352.28 rows=31775 width=11) (actual time=3998.554..4130.067 rows=32640 loops=1) > Sort Key: c.id > -> Seq Scan on contacts c (cost=0.00..1896.77 rows=31775 width=11) (actual time=0.040..326.135 rows=32501 loops=1) > Filter: (partner_id IS NULL) > Total runtime: 4611.323 ms Hmm ... even on a SPARC, it doesn't seem like it should take 4 seconds to sort 30000 rows. You can certainly see that the planner is not expecting that (it's estimating a sort cost comparable to the scan cost, which if true would put this in the sub-second ballpark). Does increasing sort_mem help? Have you considered using some other datatype than "numeric" for your keys? Numeric may be fast on Oracle but it's not amazingly fast on Postgres. bigint would be better, if you don't really need 38 digits; if you do, I'd be inclined to think about plain char or varchar keys. regards, tom lane