running a 7.4.5 engine, I'm facing this bad plan:
empdb=# explain analyze SELECT name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp empdb-# FROM v_sc_user_request empdb-# WHERE empdb-# login = 'babinow1' empdb-# LIMIT 10 ;
-> Subquery Scan vsp (cost=985.73..1016.53 rows=1103 width=12) (actual time=25.328..1668.754 rows=493 loops=31) -> Merge Join (cost=985.73..1011.01 rows=1103 width=130) (actual time=25.321..1666.666 rows=493 loops=31) Merge Cond: ("outer".id_program = "inner".id_program)
The problem to address is in this subquery. That's a total of 31 x (1668.754 - 25.328) = 50seconds (about).
Since your query is so simple, I'm guessing v_sc_user_request is a view. Can you provide the definition?
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster