> Hi,
>
> I have a java app that uses hibernate to do queries.
>
> One query on a 6.5 millions records takes about 15 seconds while the
> same one (take from the sql that shows in the consol - I configured
> hibernate to show_sql) takes about 50 ms when done with pgadmin3.
We could answer better with explain output. Something like:
prepare foo(int) as select notevalue0_.idas id, notevalue0_.value_note as value2_3_, notevalue0_.actif asactif3_,
notevalue0_.id_noteas id4_3_, notevalue0_.id_field_name asid5_3_ from note.note_value notevalue0_ where
notevalue0_.id_note=$1andnotevalue0_.actif=1;
explain analyze execute foo(<put a representative value here>);
-
As an initial guess, I'd wonder if it's guessing that for an arbitrary
id_note value that it should do a sequence scan. Are there a large number
of very common id_note values that might be throwing it off?