Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 402ED1337B39 for ; Tue, 1 Mar 2011 03:42:56 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 64093-02 for ; Tue, 1 Mar 2011 07:42:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id 342B0133616B for ; Tue, 1 Mar 2011 03:42:47 -0400 (AST) Received: by bwz15 with SMTP id 15so4366424bwz.19 for ; Mon, 28 Feb 2011 23:42:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id; bh=2IHfSHhBDYm9HLTSAimo1qQMwS3RDUvSiQkpFbQ1r9c=; b=ZUF52aaIIhcYnbpQAQGYm7aVkJ+MnpYUUUDcRoX/LoQgYwu/XfE/6hvF89wL4BALB7 wZdBNwEbEUOHefGhPmoXiVHuRQvwZVs6UiviJN2ESPsm6M+NU5rK1xJ+REWI0f5TEWIJ XMF75FikoZSpZl69/Wig/kEVmnjYivVVHsvWQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=HhSbhjELIpInxR4jr4aXUQmvO3sjbs6ndMjEi1tN+ViU80hqp30YjaYlI9fuj3j9bN zUFcKuw8Ry8IPs10bXHQHixOUyY5iKmTvTMC9jjh669AMjEwkEPqMGW62l2G5IZgp7Ar Xbnv4BZT0yuqA4FO07JPHpfu8j4WM5cdqa5yk= Received: by 10.204.82.84 with SMTP id a20mr5591187bkl.154.1298965366824; Mon, 28 Feb 2011 23:42:46 -0800 (PST) Received: from marco.localnet (gev44-1-78-228-108-65.fbx.proxad.net [78.228.108.65]) by mx.google.com with ESMTPS id u23sm3112742bkw.21.2011.02.28.23.42.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Feb 2011 23:42:45 -0800 (PST) From: Marc Cousin To: Tom Lane Subject: Re: inheritance: planning time vs children number vs column number Date: Tue, 1 Mar 2011 08:42:42 +0100 User-Agent: KMail/1.13.6 (Linux/2.6.37-ARCH; KDE/4.6.0; x86_64; ; ) Cc: Heikki Linnakangas , pgsql-performance@postgresql.org References: <201102281038.04945.cousinmarc@gmail.com> <201102281947.46590.cousinmarc@gmail.com> <4188.1298960419@sss.pgh.pa.us> In-Reply-To: <4188.1298960419@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201103010842.42128.cousinmarc@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201103/2 X-Sequence-Number: 42681 Le mardi 01 mars 2011 07:20:19, Tom Lane a =C3=A9crit : > Marc Cousin writes: > > The Monday 28 February 2011 16:35:37, Tom Lane wrote : > >> Could we see a concrete example demonstrating that? I agree with Heik= ki > >> that it's not obvious what you are testing that would have such > >> behavior. I can think of places that would have O(N^2) behavior in the > >> length of the targetlist, but it seems unlikely that they'd come to > >> dominate runtime at a mere 1000 columns. > >=20 > > I feel a little silly not having provided a test case from the start=D9= =82=C2=80=EF=BF=BD > >=20 > > A script doing a complete test is attached to this email. >=20 > I did some oprofile analysis of this test case. It's spending > essentially all its time in SearchCatCache, on failed searches of > pg_statistic. The cache accumulates negative entries for each probed > column, and then the searches take time proportional to the number of > entries, so indeed there is an O(N^2) behavior --- but N is the number > of columns times number of tables in your test case, not just the number > of columns. >=20 > The cache is a hash table, so ideally the search time would be more or > less constant as the table grows, but to make that happen we'd need to > reallocate with more buckets as the table grows, and catcache.c doesn't > do that yet. We've seen a few cases that make that look worth doing, > but they tend to be pretty extreme, like this one. >=20 > It's worth pointing out that the only reason this effect is dominating > the runtime is that you don't have any statistics for these toy test > tables. If you did, the cycles spent using those entries would dwarf > the lookup costs, I think. So it's hard to get excited about doing > anything based on this test case --- it's likely the bottleneck would be > somewhere else entirely if you'd bothered to load up some data. >=20 > regards, tom lane Yes, for the same test case, with a bit of data in every partition and=20 statistics up to date, planning time goes from 20 seconds to 125ms for the = 600=20 children/1000 columns case. Which is of course more than acceptable. Now I've got to check it's the same problem on the real environment. I thin= k=20 it has quite a few empty partitions, so no statistics for them=E2=80=A6 Thanks a lot. Marc