Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YoT6g-0004YB-UY for pgsql-performance@arkaria.postgresql.org; Sat, 02 May 2015 08:49:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YoT6f-0007v9-Gi for pgsql-performance@arkaria.postgresql.org; Sat, 02 May 2015 08:49:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YoT6d-0007v0-By for pgsql-performance@postgresql.org; Sat, 02 May 2015 08:49:03 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YoT6W-0005x9-9K for pgsql-performance@postgresql.org; Sat, 02 May 2015 08:49:02 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YoT6R-0005bP-6h for pgsql-performance@postgresql.org; Sat, 02 May 2015 10:48:51 +0200 Received: from p50856540.dip0.t-ipconnect.de ([80.133.101.64]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 02 May 2015 10:48:51 +0200 Received: from shortcutter by p50856540.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 02 May 2015 10:48:51 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Robert Klemme Subject: Re: Index Scan Backward Slow Date: Sat, 02 May 2015 10:48:40 +0200 Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p50856540.dip0.t-ipconnect.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: X-Pg-Spam-Score: -1.5 (-) 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 01.05.2015 13:06, David Osborne wrote: > Simple... that did it... thanks! > > dev=> create index on table(code,row_id); > CREATE INDEX > Time: 38088.482 ms > dev=> explain (analyse,buffers) select row_id as last_row_id from table > where code='XX' order by row_id desc limit 1; Just out of curiosity: Is there a particular reason why you do not use select max(row_id) as last_row_id from table where code='XX' ? Kind regards robert -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance