Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 641AEB5DBBD for ; Sun, 15 May 2011 22:18:37 -0300 (ADT) 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 70299-10 for ; Mon, 16 May 2011 01:18:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.9]) by mail.postgresql.org (Postfix) with ESMTP id F0BD4B5DBBC for ; Sun, 15 May 2011 22:18:29 -0300 (ADT) Received: from [192.168.1.3] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0Mgrgq-1PzhBd0jlw-00MSpT; Mon, 16 May 2011 03:18:13 +0200 Message-ID: <4DD07B4E.1020503@2ndquadrant.com> Date: Sun, 15 May 2011 21:18:06 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Craig Ringer CC: =?ISO-8859-1?Q?C=E9dric_Villemain?= , Josh Berkus , pgsql-performance@postgresql.org Subject: Re: reducing random_page_cost from 4 to 2 to force index scan References: <4DB6F4BB020000250003CEB9@gw.wicourts.gov> <2823.1305314437@sss.pgh.pa.us> <4DCD90F5.2010501@agliodbs.com> <4DD0195A.9040305@agliodbs.com> <4DD07855.8080907@postnewspapers.com.au> In-Reply-To: <4DD07855.8080907@postnewspapers.com.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:sha1CIx/m2TEp/5jwqax9EvmmTCJ6IdCN+xCAwXWD0D ruNd+OqdEKztCQpvlJi7MsV/N2LM/iE95BIlBZxTR+YDKJ2bN6 FQuXQPgrMxZa7E+TrbFJR9B7rC0SqT79nvBJZN1JByuCIEa0GR 5VdE0xm7VTjnbQwyIJU+w0ClkAD8yG4BuBvSilRpk2np2hqXgI AFxLmERkHUBgP/EgBqSv/PPYW14f6FIezdZjy7Rt0Y= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201105/231 X-Sequence-Number: 43740 Craig Ringer wrote: > AFAIK, mincore() is only useful for mmap()ed files and for finding out > if it's safe to access certain blocks of memory w/o risking triggering > heavy swapping. > > It doesn't provide any visibility into the OS's block device / file > system caches; you can't ask it "how much of this file is cached in RAM" > or "is this range of blocks in this file cached in RAM". > You should try out pgfincore if you think this can't be done! > Even if you could, it's hard to see how an approach that relied on > asking the OS through system calls about the cache state when planning > every query could be fast enough to be viable. > You can't do it in real-time. You don't necessarily want that to even if it were possible; too many possibilities for nasty feedback loops where you always favor using some marginal index that happens to be in memory, and therefore never page in things that would be faster once they're read. The only reasonable implementation that avoids completely unstable plans is to scan this data periodically and save some statistics on it--the way ANALYZE does--and then have that turn into a planner input. The related secondary idea of just making assumptions about small tables/indexes, too, may be a useful heuristic to layer on top of this. There's a pile of ideas here that all seem reasonable both in terms of modeling real-world behavior and as things that could be inserted into the optimizer. As usual, I suspect that work is needs to be followed by a giant testing exercise though. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books