Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0671C1337B69 for ; Thu, 3 Feb 2011 11:43:57 -0400 (AST) 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 65314-03 for ; Thu, 3 Feb 2011 15:43:49 +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 1C37E1337B2F for ; Thu, 3 Feb 2011 11:43:48 -0400 (AST) Received: by fxm20 with SMTP id 20so1332796fxm.19 for ; Thu, 03 Feb 2011 07:43:48 -0800 (PST) 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=uB3rjIemUVMFpJBroEFs+XnrOEpQs1ZogM8V4z9fcPo=; b=jWuDE8waTH5XqoR7+gw/7fSxX4EESovCdmJAN4PYNjf30hDse1q5pYO+avutM7bN3c C4jXqj5dVDjtS+kNRvOJUw7R/iB3Ij5yROFQyrcJA7jltQBsxKGRzSyfX2zxAi6ODoae rNWbAbYWcBrmhcW9zYqkNQcWaglA+Ma1K+g+8= 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=wvks5x54m4c+GPUB8Wpx+IMGBD9cHWdJZ1VzuDNxuSq0eprS+hVdkruCjGFe6JOulR ztuhC6ZrdxdTX08ssb0PpjDZ8WSxiIqQ+za9D6ee8PuaGc8YmXe8uDODFoHzr/BugYOT SsPB+P1ya78yHmqpeIWS7FcaTyNFbMHeJxodw= Received: by 10.223.123.142 with SMTP id p14mr10060950far.56.1296747828830; Thu, 03 Feb 2011 07:43:48 -0800 (PST) Received: from [10.1.1.57] (skuns.zoral.com.ua [91.193.166.194]) by mx.google.com with ESMTPS id 5sm334246fak.47.2011.02.03.07.43.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Feb 2011 07:43:47 -0800 (PST) Message-ID: <4D4ACD33.903@gmail.com> Date: Thu, 03 Feb 2011 17:43:47 +0200 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Robert Haas CC: Jon Nelson , Mladen Gogala , Andrew Dunstan , Bruce Momjian , Tom Lane , "david@lang.hm" , Craig Ringer , "pgsql-performance@postgresql.org" Subject: Re: [HACKERS] Slow count(*) again... References: <201102012247.p11Ml6u02682@momjian.us> <4D48914B.4050403@dunslane.net> <4D489AD1.1010105@vmsinfo.com> <4D499E55.4020107@vmsinfo.com> <4D4A7B69.2020704@gmail.com> In-Reply-To: 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: 201102/80 X-Sequence-Number: 42218 03.02.11 17:31, Robert Haas написав(ла): > >> May be introducing something like 'AutoAnalyze' threshold will help? I mean >> that any insert/update/delete statement that changes more then x% of table >> (and no less then y records) must do analyze right after it was finished. >> Defaults like x=50 y=10000 should be quite good as for me. > That would actually be a pessimization for many real world cases. Consider: > > COPY > COPY > COPY > COPY > COPY > COPY > COPY > COPY > COPY > COPY > COPY > COPY > COPY > SELECT If all the copies are ~ same in size and large this will make it: COPY ANALYZE COPY ANALYZE COPY COPY ANALYZE COPY COPY COPY COPY ANALYZE COPY COPY COPY COPY COPY SELECT instead of COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY ANALYZE (manual, if one is clever enough) SELECT So, yes this will add 3 more analyze, but 1) Analyze is pretty cheap comparing to large data loading. I'd say this would add few percent of burden. And NOT doing analyze manually before select can raise select costs orders of magnitude. 2) How often in real world a single table is loaded in many COPY statements? (I don't say it's not often, I really don't know). At least for restore it is not the case, is not it? 3) default thresholds are things to discuss. You can make x=90 or x=200 (latter will make it run only for massive load/insert operations). You can even make it disabled by default for people to test. Or enable by default for temp tables only (and have two sets of thresholds) 4) As most other settings, this threshold can be changed on up to per-query basis. P.S. I would also like to have index analyze as part of any create index process. Best regards, Vitalii Tymchyshyn