Re: planner/optimizer question
От | Zeugswetter Andreas SB SD |
---|---|
Тема | Re: planner/optimizer question |
Дата | |
Msg-id | 46C15C39FEB2C44BA555E356FBCD6FA42127A2@m0114.s-mxs.net обсуждение исходный текст |
Ответ на | planner/optimizer question (Philip Warner <pjw@rhyme.com.au>) |
Список | pgsql-hackers |
> Bue this executes slowly: > > explain select * from flow_stats where src_addr='1.1.1.1' order by > log_date desc limit 3; > NOTICE: QUERY PLAN: > > Limit (cost=0.00..796.61 rows=3 width=116) > -> Index Scan Backward using flow_stats_ix4 on flow_stats > (cost=0.00..81594.14 rows=307 width=116) > > Where > > flow_stats_ix4 is (log_date) > flow_stats_ix6 is (src_addr,log_date) This would be a possible optimization, that other db's also seem to miss (at least in older versions). The trick with all ot them is to include the =constant restricted column in the order by: select * from flow_stats where src_addr='1.1.1.1' order by src_addr desc, log_date desc limit 3; Note, that because src_addr is fixed it won't change the result. Andreas
В списке pgsql-hackers по дате отправления: