Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id DD5D81337B49 for ; Fri, 18 Mar 2011 07:52:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 08387-10 for ; Fri, 18 Mar 2011 10:51:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 26F021337B43 for ; Fri, 18 Mar 2011 07:51:56 -0300 (ADT) Received: by fxm17 with SMTP id 17so3549720fxm.19 for ; Fri, 18 Mar 2011 03:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=AaENneTds1JsKT7XirLXuyafY81f3KYPM7tp8IbBtq4=; b=nUvIOUdxg2GgeSNhF0XLE1QXO61SRiWHy4B/YJOOBQMLKvKHeJiPwV1q06blTNTBtC I6gXvm+wXayP7YX5w+ahagYTs/WkKFqFfxKIlxsTBjkXscsGBOlzJa5jPZnWvMJdlpSn UFFOQGM/s2ua3xOxeKIXiF0rXVEcJkeqWvrY0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=o1I3gPXdrVz7CgJ1TZ8h8S33OyOEDfDB516PMm4vgyzEo7REBCGRyoTXKuHuDYcF3k I8d7BANkVsc/Y8vFczdoXEe0MZxs8hpeTgzcZHX74dyuqaTMwbZoIi3fleXJKdysbRwV lj0+ifYkZcY+YehbaYn9yJwXE6fsB0VLCtUQc= Received: by 10.223.2.205 with SMTP id 13mr1038938fak.138.1300445515539; Fri, 18 Mar 2011 03:51:55 -0700 (PDT) Received: from [10.1.1.57] (skuns.zoral.com.ua [91.193.166.194]) by mx.google.com with ESMTPS id e17sm402532fak.0.2011.03.18.03.51.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Mar 2011 03:51:53 -0700 (PDT) Message-ID: <4D833953.7080607@gmail.com> Date: Fri, 18 Mar 2011 12:52:03 +0200 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: =?UTF-8?B?QW5zc2kgS8Okw6RyacOkaW5lbg==?= CC: "pgsql-performance@postgresql.org" Subject: Re: Disabling nested loops - worst case performance References: <4D8306A7.7020205@thl.fi> In-Reply-To: <4D8306A7.7020205@thl.fi> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.046 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201103/208 X-Sequence-Number: 42887 18.03.11 09:15, Anssi Kääriäinen написав(ла): > Hello list, > > I am working on a Entity-Attribute-Value (EAV) database using > PostgreSQL 8.4.7. The basic problem is that when joining multiple > times different entities the planner thinks that there is vastly less > rows to join than there is in reality and decides to use multiple > nested loops for the join chain. This results in queries where when > nested loops are enabled, query time is somewhere around 35 seconds, > but with nested loops disabled, the performance is somewhere around > 100ms. I don't think there is much hope for getting better statistics, > as EAV is just not statistics friendly. The values of an attribute > depend on the type of the attribute, and different entities have > different attributes defined. The planner has no idea of these > correlations. Hello. If your queries work on single attribute, you can try adding partial indexes for different attributes. Note that in this case parameterized statements may prevent index usage, so check also with attribute id inlined. Best regards, Vitalii Tymchyshyn