X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AB1364761C0 for ; Mon, 24 Mar 2003 17:08:50 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D7DEE475F09 for ; Mon, 24 Mar 2003 17:08:48 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2OM8oub020750; Mon, 24 Mar 2003 17:08:50 -0500 (EST) To: Oleg Lebedev Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query In-reply-to: <993DBE5B4D02194382EC8DF8554A5273113E5F@postoffice.waterford.org> References: <993DBE5B4D02194382EC8DF8554A5273113E5F@postoffice.waterford.org> Comments: In-reply-to Oleg Lebedev message dated "Mon, 24 Mar 2003 14:46:09 -0700" Date: Mon, 24 Mar 2003 17:08:50 -0500 Message-ID: <20749.1048543730@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/169 X-Sequence-Number: 1467 Oleg Lebedev writes: > I just ran the query you sent me and attached the output of EXPLAIN > ANALYZE as TOMs_plan.txt > It did not speed up the query significantly. Nope. I was hoping to see a faster-start plan, but given the number of rows involved I guess it won't change its mind. You're going to have to think about a more intelligent approach, rather than minor tweaks. One question: since objectid is evidently a primary key, why are you doing a subselect for the first part? Wouldn't it give the same result just to say "m.activity = '347667'" in the top-level WHERE? As for the second part, I think you'll have to try to rewrite it as a join with the media table. regards, tom lane