Hi all. In PG 8.2.4 I have a 4+M rows table like this: create table t ( f1 bigint, f2 text, f3 text ); create index i_t_1 on t( f1 ); create index i_t_2 on t( f2 ); create index i_t_2 on t( f3 ); I'd need to write a stored function that should do the following: for rec in select * from t order by f2,f2 loop ... end loop; This loop is increadibly slow. Infact the friendly explain tells me that: test=# explain select * from t order by f2,f3; QUERY PLAN --------------------------------------------------------------------------------- Sort (cost=958786.20..970734.55 rows=4779338 width=28) Sort Key: f2,f3 -> Seq Scan on t (cost=0.00..85501.38 rows=4779338 width=28) I'd like to know a hint about a technicque to avoid the sequential scan! Thanks. -- Vincenzo Romano -- Maybe Computer will never become as intelligent as Humans. For sure they won't ever become so stupid. [VR-1988] ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match