Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 313081337B4E for ; Sat, 5 Feb 2011 04:49:34 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 97532-09 for ; Sat, 5 Feb 2011 08:49:26 +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 7517D133616B for ; Sat, 5 Feb 2011 04:49:26 -0400 (AST) Received: from [192.168.1.6] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0M5tBF-1Q5NbY2iPh-00yH1d; Sat, 05 Feb 2011 09:49:26 +0100 Message-ID: <4D4D0F14.7020500@2ndquadrant.com> Date: Sat, 05 Feb 2011 03:49:24 -0500 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Tobias Brox CC: pgsql-performance@postgresql.org Subject: Re: table partitioning and select max(id) References: <4D4CDA0C.20000@2ndquadrant.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:hIIQ5yVHE1ZY50xW1F+r17PAzwgWHo7fnUek5fHZBSE 5nOPqvOpNdp5BjgSxHTgqNpTL6mJ7RfUl5wKG7fb/jaAJ1Jz/f oL+kU5oHqi8zqEZ1IUqRiRW+wGFE0yf77JZoCvrIXHi9OqXQJh uZLaENvMu6RwT7sD2ivxFZASbCjsryW1BRYfOdm+L+7cNMgSsp YNZjC15wOfmrVe1X/d1zs1q6FNjSViGaAloSo2NsGc= 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: 201102/242 X-Sequence-Number: 42380 Tobias Brox wrote: > I did test "select id from table order by id desc limit 1" on my parent table > yesterday, it would still do the seq-scan. Even adding a > where-restriction to make sure only one partition was queried I still > got the seq-scan. > Right; you actually have to direct the query toward the specific partition by name, nothing run against the parent table will work. The new logic for 9.1 essentially splits the query into this alternate form, runs it against every partition individually, then combines the results. If you can afford to wait for 9.1, that is certainly the easy path here. It just works out of the box in that version. -- 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