Re: Convincing the query planner to play nice
От | Jeff Janes |
---|---|
Тема | Re: Convincing the query planner to play nice |
Дата | |
Msg-id | CAMkU=1zU5_h1mcadqvzN_h5DMxiYZPk4ZG_n7F5iS_iz3Xhg-g@mail.gmail.com обсуждение исходный текст |
Ответ на | Convincing the query planner to play nice (Timothy Kane <tim.kane@gmail.com>) |
Ответы |
Re: Convincing the query planner to play nice
|
Список | pgsql-general |
On Sat, Aug 10, 2013 at 10:32 AM, Timothy Kane <tim.kane@gmail.com> wrote: > > Hi all, > > I seem to be having some grief with the 9.1.9 query planner favouring an > index scan + merge join, over a sequential scan + hash join. > Logically I would have considered the index+merge to be faster, as suggested > by the explain output - but in practice, it is in fact slower by orders of > magnitude. > > In my timings below, I've tried to reduce the impact of any OS or > shared_buffer level caching (restarting postgres, and flushing OS cache > between queries-). Are you sure that that is the right thing to do? It seems unlikely that your production server is constantly executing your query from a cold start. Why test it that way? > > I've provided my settings as shown: > > > =# show seq_page_cost; > seq_page_cost > --------------- > 1 > (1 row) > > Time: 0.355 ms > =# show random_page_cost; > random_page_cost > ------------------ > 2.2 > (1 row) Given that you are testing your query from a cold start (and assuming against odds that that is the correct thing to do), 2.2 is probably a factor of 20 too small for this setting. Cheers, Jeff
В списке pgsql-general по дате отправления: