Bug #809: View not using index
От | pgsql-bugs@postgresql.org |
---|---|
Тема | Bug #809: View not using index |
Дата | |
Msg-id | 20021101014052.4B6094758BD@postgresql.org обсуждение исходный текст |
Ответы |
Re: Bug #809: View not using index
|
Список | pgsql-bugs |
Philip Warner (pjw@rhyme.com.au) reports a bug with a severity of 2 The lower the number the more severe it is. Short Description View not using index Long Description It seems that a UNION view fails to use underlying table indexes. This is a major pain when using subclassed tables whichare updated frquently - even if the underlying tables are vacuumued regularly, the seq scan can take a very long time. Sample Code create table t1(id serial,name text); insert into t1(name) values('fred'); insert into t1(name) select name || id from t1; insert into t1(name) select name || id from t1; ...keep doing this until the table is big create table t2(id serial,name text); create view tv as select id,name from t1 union select id,name from t2; vacuum full; analyze; explain select * from t1 where id=1; NOTICE: QUERY PLAN: Index Scan using t1_id_key on t1 (cost=0.00..3.01 rows=1 width=34) explain select * from tv where id=1; NOTICE: QUERY PLAN: Subquery Scan tv (cost=24029.48..24821.48 rows=15840 width=36) -> Unique (cost=24029.48..24821.48 rows=15840 width=36) -> Sort (cost=24029.48..24029.48 rows=158401 width=36) -> Append (cost=0.00..2739.00 rows=158401 width=36) -> Subquery Scan *SELECT* 1 (cost=0.00..2739.00 rows=158400 width=34) -> Seq Scan on t1 (cost=0.00..2739.00 rows=158400 width=34) -> Subquery Scan *SELECT* 2 (cost=0.00..0.00 rows=1 width=36) -> Seq Scan on t2 (cost=0.00..0.00 rows=1 width=36) No file was uploaded with this report
В списке pgsql-bugs по дате отправления: