> 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_.id as id, notevalue0_.value_note as value2_3_, notevalue0_.actif as actif3_, notevalue0_.id_note as id4_3_, notevalue0_.id_field_name as id5_3_ from note.note_value notevalue0_ where notevalue0_.id_note=$1 and notevalue0_.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? ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org