> 2007/10/22, Martin Marques <martin@bugs.unl.edu.ar>:
>> Pavel Stehule wrote:
>>> Hello
>>>
>>> I am unsure, did you check config values?
>> Don't know which ones you are talking about, but all enable_* are set to on.
>>
>> Anything else?
>>
>
> shared_buffers
> work_mem
> effective_cache_size
>
> Pavel
Well, the cost_* values might be interesting too. That is
seq_page_cost
random_page_cost
cpu_tuple_cost
cpu_index_tuple_cost
cpu_operator_cost
effective_cache_size
(the first one is available in 8.2 only). My guess is that there are
different values, and the 8.2 overestimates the index scan - which seems
to be incorrect.
Try to disable the seqscan in the 8.2 database (set enable_seqscan =
off), and run the explain analyze again. This time it should choose
different query plan - maybe the index scan as in 8.1.
Another thing you might try is setting the cost values to the same
values in both databases - it might help.
And what does it mean by 'same data' - have you vacuumed / analyzed both
of them? What does this return:
select relname, relpages, reltuples from pg_class where relname =
'prestamos' or relname='prestamos_objetos_devuelto_idx';
That should return number of tuples / occupied pages in the table and index.
Tomas