Hi Andy! Thanks a lot for your hints! Indeed the problem was on my side. Some Hibernate tuning solved the problem (and I was able to speedup the query using IN). The real problem was that Hibernate using unprepared queries if you create a native query, but prepares the query if you use JP-QL (very odd behavior). Thanks anyway for your help! Kind regards Thilo > I am going to guess the slow part is sending 1M different queries back and forth from client to server. You could try batching them together: > > DELETE FROM table1 WHERE table2_id in (11242939, 1,2,3,4,5...., 42); > > Also are you preparing the query? > > -Andy > > -- > Sent via pgsql-performance mailing list (pgsql-performa...@xxxxxxxxxxxxxx) > To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-performance -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance