Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQvmC-0005dQ-T1 for pgsql-performance@arkaria.postgresql.org; Sat, 13 Apr 2013 08:25:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQvmB-0000Lr-Nk for pgsql-performance@arkaria.postgresql.org; Sat, 13 Apr 2013 08:25:35 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQvmA-0000Lm-OP for pgsql-performance@postgresql.org; Sat, 13 Apr 2013 08:25:34 +0000 Received: from mail-ee0-f42.google.com ([74.125.83.42]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQvm7-0003vd-I2 for pgsql-performance@postgresql.org; Sat, 13 Apr 2013 08:25:33 +0000 Received: by mail-ee0-f42.google.com with SMTP id d4so1528983eek.15 for ; Sat, 13 Apr 2013 01:25:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding :x-gm-message-state; bh=MZoBJCQPUxYywpOHv/shAmSSE/mmuqC/AsMu4xqPB6c=; b=P8eBeJIz4icDU5QIEIG7f1BxOlzGK5PoeSlASLLkhjsBm/tECgLvxlszds4PXHlvIO 9jER0q5RpMcpVaphR/Rv37SvgaksRS8CLPeyKN0IgrJgExdKer/rje8gxT3PnzX3Qm38 z6kmWO8HqjICESGgsNDtvt7884oHcRzzS/7JyAHSRw6M72lFjgsC/lnJBAfQJKJrFKVT f1ISEZ7n7Rpjo98yTCRHARMIVnRkRhXhOtVXRVqHcIVDR9aQ4uEqhmWd9cHGRYSc13Bs wYwGDR21csnjCFVjGKXhLW6wXMDt70W9grFtI67BcgXOpajsHpbBly7WERVpkzDgED0X /IHg== X-Received: by 10.15.99.201 with SMTP id bl49mr36569521eeb.43.1365841530033; Sat, 13 Apr 2013 01:25:30 -0700 (PDT) Received: from [94.253.149.80] (cpezg-94-253-149-80-cbl.xnet.hr. [94.253.149.80]) by mx.google.com with ESMTPS id n48sm1661233eeg.12.2013.04.13.01.25.28 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Apr 2013 01:25:29 -0700 (PDT) Message-ID: <5169168D.4000903@ngs.hr> Date: Sat, 13 Apr 2013 10:25:49 +0200 From: Rikard Pavelic User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: limit is sometimes not pushed in view with order X-Enigmail-Version: 1.3.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkMua24P1WX1aeLQ1q4KuonPS2KfrcwR6p4J1aAAKOwYgY+dHB+VprH5SGjP7eL4dfJD4Rn 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 I was investigating some performance issues and stumbled upon this behavior: create table main_table (i serial primary key, data varchar, ord int); create view main_view_order as select m.i, m.data, m.ord from main_table m order by m.i desc; insert into main_table select i, i::text, i/10 from generate_series(1,1000000) i; create index ix_ord on main_table(ord); analyze main_table; explain analyze select * from main_view_order m where m.ord >= 5000 and m.ord <= 5500 limit 10; Limit (cost=0.00..69.01 rows=10 width=14) (actual time=330.943..330.951 rows=10 loops=1) -> Index Scan Backward using main_table_pkey on main_table m (cost=0.00..36389.36 rows=5281 width=14) (actual time=330.937..330.940 rows=10 loops=1) Filter: ((ord >= 5000) AND (ord <= 5500)) Total runtime: 330.975 ms I havent found it on TODO or in archives so I'm wondering if this is a known behavior. Regards, Rikard -- Rikard Pavelic http://www.ngs.hr/ -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance