Posty

Wyświetlam posty z etykietą Spring

Spring/Hibernate optimization: JPA with @OneToOne mapping

Lately I wanted to see how Hibernate actually construct sql statements. And it seems like it makes somtimes unnecessary joins. Those are my playground's results. Repo:  https://github.com/toficzak/social-app Setup: Post repository consists of 3 methods: Sql generated by Hibernate: How did I measure execution time:    Simple select measure By author id: 1952090.938 By author (User provided): 1048579.671 By author (User not provided): 1021450.464 By custom query: 935087.347 My custom JPA query is the fastest option - it skips whole User join section. But why is it needed at all? Seems like an error in my design.

Project: Simple filesystem

Obraz
Introduction Music: Some random YouTube suggestion ,  Barns Courtney - Fire , Taco Hemingway - Grubo-chude psy Repository: https://github.com/KKucharczyk/Filesystem Resource management is all around us. On macro scale, the sand is just a resource. Resource we, people are constantly using in construction industry. Food is a resource we are dealing with every day. Amount of wheat in given country is also a resource. And resources usually needs to be managed. As a programmer, I tend to meet resource management also, on a smaller, micro scale. My Ubuntu operating system with its shell allows me to organize my files. My applications are constantly using some resources of my computer's or servers' they are working on, which I try to optimize. Databases are working on huge sets of data and it's my job to predict and handle situation, when requested resource is available or does not exist. Managing assets is a common thing in projects. I have worked in the past ...

Messing with PostgreSQL: b-tree indexes, likes and operator classes

I can do a lot with JPA. Working with database is not a hard thing in Java environment. Java EE has a pretty easy standard when it comes to working with data, Spring makes configuration even easier and Hibernate takes care of almost every problem with already created and tested solutions. Although lately I started to peek at the possible optimization. Since I have came to as little Entity Manager calls as possible, there is not much to do in the code. So I decided it is, finally, time to dive deeper into databases and their magic world of indexes, analyzing, likes, trigrams, etc. I am used to work with PostgreSQL RDMS, so this post will be mostly in its dialect. What I already knew? If you want your database to work faster - index its appopriate fields. Basic knowledge. But... why? How does the indexing work? Those are my new questions. And to get some answers, since lately I started to work with Spring Boot (literally just searched to see, how correctly write it :o ) and Sprin...