Re: [HACKERS] Slow count(*) again...

Bruce Momjian <bruce@momjian.us>

From: Bruce Momjian <bruce@momjian.us>
To: Greg Smith <greg@2ndquadrant.com>
Cc: Mladen Gogala <mladen.gogala@vmsinfo.com>, Robert Haas <robertmhaas@gmail.com>, Andrew Dunstan <andrew@dunslane.net>, Tom Lane <tgl@sss.pgh.pa.us>, "david@lang.hm" <david@lang.hm>, Craig Ringer <craig@postnewspapers.com.au>, Vitalii Tymchyshyn <tivv00@gmail.com>, "pgsql-performance@postgresql.org" <pgsql-performance@postgresql.org>
Date: 2011-02-03T00:13:44Z
Lists: pgsql-hackers, pgsql-performance
Greg Smith wrote:
> Mladen Gogala wrote:
> > Greg, how many questions about queries not using an index have you 
> > seen? There is a reason why people keep asking that. The sheer number 
> > of questions like that on this group should tell you that there is a 
> > problem there. There must be a relatively simple way of influencing 
> > optimizer decisions. 
> 
> I think that's not quite the right question.  For every person like 
> yourself who is making an informed "the optimizer is really picking the 
> wrong index" request, I think there are more who are asking for that but 
> are not actually right that it will help.  I think you would agree that 
> this area is hard to understand, and easy to make mistakes about, yes?  
> So the right question is "how many questions about queries not using an 
> index would have actually benefitted from the behavior they asked for?"  
> That's a much fuzzier and harder to answer question.

Agreed.  I created an FAQ entry years ago to explain this point and tell
people how to test it:

	http://wiki.postgresql.org/wiki/FAQ#Why_are_my_queries_slow.3F_Why_don.27t_they_use_my_indexes.3F

Once I added that FAQ we had many fewer email questions about index
choice.

> > With all due respect, I consider myself smarter than the optimizer.  
> > I'm 6'4", 235LBS so telling me that you disagree and that I am more 
> > stupid than a computer program,  would not be a smart thing to do. 
> > Please, do not misunderestimate me.
> 
> I remember when I used to only weigh that much.  You are lucky to be 
> such a slim little guy!
> 
> Oh, I guess I should add, :)

Oh, wow, what a great retort.  :-)

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +