André Volpato <andre.volpato@ecomtecnologia.com.br> writes:
> Gregory Stark escreveu:
>> André Volpato <andre.volpato@ecomtecnologia.com.br> writes:
>>
>> I think the answer is that if you have bad statistics you'll get a bad plan
>> and which bad plan is going to be pretty much random.
>>
> I believe the statistics are ok, I´ve runned vacuum analyze before all those
> tries.
Sorry, I should have said "bad estimates". That is, because of the
j*1.5 BETWEEN 3000000 AND 4000000
clause the optimizer isn't going to be able to come up with a good estimate of
how many rows that will match. What plan it picks when it has such a bad
estimate is going to be pretty random, dependant on just what plans would be
good in a situation entirely unrelated to the reality.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's Slony Replication support!