From: Rikard Pavelic <rikard@ngs.hr>
To: pgsql-performance@postgresql.org
Subject: limit is sometimes not pushed in view with order
Date: Sat, 13 Apr 2013 10:25:49 +0200
Message-ID: <5169168D.4000903@ngs.hr> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: rikard@ngs.hr
Subject: Re: limit is sometimes not pushed in view with order
In-Reply-To: <5169168D.4000903@ngs.hr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox