Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 02A719FB65A for ; Thu, 5 Apr 2007 15:46:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 65858-03 for ; Thu, 5 Apr 2007 15:46:10 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.230]) by postgresql.org (Postfix) with ESMTP id EA41A9FB645 for ; Thu, 5 Apr 2007 15:46:09 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id 70so479695wra for ; Thu, 05 Apr 2007 11:46:09 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=aS6KoPlRD8e7UTcMgykjGe6kQozEdL0Q+e73CSMxJjEU2U35qwFoN46MjjjjlVmO+XqVFxtvQ85Vv+jN5YVKwwrn/qmZOLpy5RJ2Lr8S9gI8Aq435v1O5Gf8SC7xdc7oqVbwIwDf6/+7YMLg+btDrVn/kZYdXPSI13BC53xU+5g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=m7tMi8MFYtMDPHEBHB14Tk8IGOyT+E58XokLK7g4mPLlf/GK6jEumK71nflXyGQLLt6fJu5QXZMHQiNX2pIo+Ldd7B+UOME1dBxwoDwp8jt4s4FX1TYkgC6lp/1OQudNKu90v0x73RWgVdvEcfckGsy0y8Eh6RBXN2bgF/SIrsE= Received: by 10.114.180.1 with SMTP id c1mr834402waf.1175798768378; Thu, 05 Apr 2007 11:46:08 -0700 (PDT) Received: by 10.114.157.12 with HTTP; Thu, 5 Apr 2007 11:46:08 -0700 (PDT) Message-ID: Date: Thu, 5 Apr 2007 12:46:08 -0600 From: "Jonathan Ellis" To: pgsql-performance@postgresql.org Subject: Premature view materialization in 8.2? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: b28a428dc57e0b68 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/116 X-Sequence-Number: 23993 I have a query hitting a view that takes 0.15s on 8.1 but 6s on 8.2.3: select party_id from clan_members_v cm, clans c where cm.clan_id = c.id and c.type = 'standard' The problem seems to be that clan_members_v contains a call to an expensive function: create or replace view clan_members_v as select cm.clan_id, cm.user_id, cp.party_id, cm.date_accepted, p.name as party_name, p_tp_total(p.id)::int as tp_total from clan_members cm, clan_participants cp, parties p where cm.user_id = p.user_id and p.id = cp.party_id ; p_tp_total takes around 50ms per row. If I create clan_members_v without the function call, the original query's speed goes to the 150ms range on 8.2 as well. Is this a regression, or a "feature" of 8.2?