Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 86E4B9F9D51 for ; Mon, 27 Aug 2007 10:14:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 89049-03 for ; Mon, 27 Aug 2007 10:14:37 -0300 (ADT) X-Greylist: delayed 00:16:24.763614 by SQLgrey-1.7.5 Received: from narcizas.serveriai.lt (narcizas.serveriai.lt [84.15.56.18]) by postgresql.org (Postfix) with ESMTP id 27DA49F9D4E for ; Mon, 27 Aug 2007 10:14:45 -0300 (ADT) Received: from [78.63.3.21] (helo=[192.168.253.104]) by narcizas.serveriai.lt with esmtpa (Exim 4.50) id 1IPe9j-0005Fi-Sa for pgsql-performance@postgresql.org; Mon, 27 Aug 2007 15:57:24 +0300 Subject: Re: partitioned table and ORDER BY indexed_field DESC LIMIT 1 From: Tomas Tamosaitis To: pgsql-performance@postgresql.org In-Reply-To: <8cac8dd0708240153p4f3ef2d9xae912259926d860@mail.gmail.com> References: <8cac8dd0708240153p4f3ef2d9xae912259926d860@mail.gmail.com> Content-Type: text/plain; charset=utf-8 Date: Mon, 27 Aug 2007 15:57:29 +0300 Message-Id: <1188219449.8210.4.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 8bit X-MailScanner-Information: http://www.serveriai.lt/ X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-MailScanner-From: tomas.tamosaitis@connecty.lt X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.157 tagged_above=0 required=5 tests=BAYES_50=0.001, SUBJECT_FUZZY_TION=0.156 X-Spam-Level: X-Archive-Number: 200708/320 X-Sequence-Number: 26450 Pn, 2007 08 24 14:53 +0600, Anton rašė: > Hi. > > I just created partitioned table, n_traf, sliced by month > (n_traf_y2007m01, n_traf_y2007m02... and so on, see below). They are > indexed by 'date_time' column. > Then I populate it (last value have date 2007-08-...) and do VACUUM > ANALYZE ON n_traf_y2007... all of it. > > Now I try to select latest value (ORDER BY date_time LIMIT 1), but > Postgres produced the ugly plan: > > =# explain SELECT * FROM n_traf ORDER BY date_time DESC LIMIT 1; > QUERY PL can you test performance and send explain results of select like this : select * from n_traf where date_time = (select max(date_time) from n_traf); i have similar problem with ~70M rows table (then using ordering), but my table not partitioned. I`m interesting how this select will works on partitioned table. -- Pagarbiai, Tomas Tamošaitis Projektų Vadovas Connecty Skype://mazgis1009?add Mob: +370 652 86127 e-pastas: tomas.tamosaitis@connecty.lt web: www.connecty.lt