Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5Z6y-0003yV-Ae for pgsql-performance@arkaria.postgresql.org; Wed, 25 May 2016 13:44:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b5Z6x-0007iJ-PJ for pgsql-performance@arkaria.postgresql.org; Wed, 25 May 2016 13:44:35 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b5Z6x-0007i9-6n for pgsql-performance@postgresql.org; Wed, 25 May 2016 13:44:35 +0000 Received: from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1b5Z6u-0002dW-0I for pgsql-performance@postgresql.org; Wed, 25 May 2016 13:44:33 +0000 Received: by mail-io0-x22f.google.com with SMTP id t40so32411873ioi.0 for ; Wed, 25 May 2016 06:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=P17FneLcJ0mIN3flpyyod2WUexjGb1lAw7RW2VXAOKw=; b=YpPr+9ZWtptF8ziaeHUrOGkCEu5L/1kikLq5Bdh3IeUxHD2Kj7jXE265BkeazoDOFw nTm6Le5aWALODehVRpGVPHkTL+HhF5t8rEyckbp+0jNsdIGJNP3tMMzojjISfNbYyhwg e+nfjhpk84EnIOx2skX0Sy6Z1CCwz/0HEReRMsD2w4W5Id9m1hJ8L2KWbCaFj28m18wE ffsi//P6FIQ9/pTGBTiUevq0VSauFV1XsWbE8stmFQOvwDkYWNQJoeI14P4RSH4OFDXx OfBlLdj5Bo+1So1803OFRTgH/pTcETTJU1JPWNsw5RPURXoYceFIADQjlym+3KNgnSR9 KXEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=P17FneLcJ0mIN3flpyyod2WUexjGb1lAw7RW2VXAOKw=; b=k1OHGlM4O5JOZSOoctnrxg9fpdTiRJMhdH0tCpEa0V/JXFnpgFg1d2JbRCQsw3aKTF AHpHi/TvLIfInfxqvpLuPJgMom5H2i36bTFs3AaW2aPObF6nWZ8KwIS+UyBvxCeNv1RV 4U+ZhILDK4YGFOb0f0ZsIXpc89V/lQ3dpTx0t7NkFGvh4c+osLxDZOfSYT5qFWsR2FQG qgyT3P6upfxSQIK5Mf6YrnRIbXLrVNuW77BX65yxeWMOh7YMH8RhEvtgXTyvCFJmThl7 39fe0h1ibwU22fJ05/GJBhh9F54iXWWQ7BHOwfmX5l4zjDnptecFpY1v6rS4WfyDXv2d WZEQ== X-Gm-Message-State: ALyK8tK5uZCSV/b1OUlLMLlKGjvBOOAUoLA23WgkE3JtN9qlW4UMLT2or/Aw+B9+fUFGbw== X-Received: by 10.107.9.170 with SMTP id 42mr3716063ioj.53.1464183871040; Wed, 25 May 2016 06:44:31 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id w70sm2824467itc.4.2016.05.25.06.44.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2016 06:44:30 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 1B38E801761; Wed, 25 May 2016 08:45:25 -0500 (CDT) Date: Wed, 25 May 2016 08:45:25 -0500 From: Justin Pryzby To: pgsql-performance@postgresql.org Subject: Re: index fragmentation on insert-only table with non-unique column Message-ID: <20160525134524.GA21220@telsasoft.com> References: <20160524173914.GA11880@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Tue, May 24, 2016 at 09:16:20PM -0700, Peter Geoghegan wrote: > On Tue, May 24, 2016 at 10:39 AM, Justin Pryzby wrote: > > Postgres seems to assume that the high degree of correlation of the table > > column seen in pg_stats is how it will get data from the index scan, which > > assumption seems to be very poor on what turns out to be a higly fragmented > > index. Is there a way to help it to understand otherwise?? > > Your complaint is vague. Are you complaining about the planner making > a poor choice? I don't think that's the issue here, because you never > made any firm statement about the planner making a choice that was > worth than an alternative that it had available. I was thinking there a few possible places to make improvements: the planner could have understood that scans of non-unique indices don't result in strictly sequential scans of the table, the degree of non-sequentialness being determined by the column statistics, and perhaps by properties of the index itself. Or the INSERT code or btree scan could improve on this, even if tuples aren't fully ordered. > If you're arguing for the idea that B-Trees should reliably keep > tuples in order by a tie-break condition, that seems difficult to > implement, and likely not worth it in practice. I had the awful idea to change the index to use (recordopeningtime,ctid). Maybe somebody will convince me otherwise, but may actually work better than trying to reindex this table daily by 4am. Thanks, Justin -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance