Hibernate Select Query Running Slow in Portioned Table

I have some performance issues in the Spring boot Project and PostgreSQL database.

Assume there is a large table, about 20 million records in the PostgreSQL database.

I use the spring crud Repository class to fetch records.

in a non-partitioned table, everything is ok and query data is very fast. ~100 milliseconds. when I switch the target table to a partitioned one, it turns into a performance issue. the same query takes to long about 1500 milliseconds.

The partitioned table is based on user_id and also query search is based on user_id.

There are some mapping entities with the base entity.

The same query execution in the database console is so fast. about 100 milliseconds.

Anybody can help me?

Like on StackOverflow, we can’t really help you unless you provide us more information. Since this might be a PostgreSQL related issue, I’d suggest you give the PostgreSQL experts that asked for more information in the StackOverflow comment section the details they need, so they can point you to the right direction.