Sobes.tech

What approaches can be used to improve the efficiency of data insertion operations after index implementation?

Junior — Middle
160

Read the code, determine what will be output at the end of program execution.

159

How to view SQL queries sent by JPA/Hibernate to the database?

158

Why is a foreign key constraint needed? Can't we do without it?

158

Are you ready to participate in support of services in production, on duty?

157

Read the code and highlight errors @Component public class AuthorSearchService { @Autowired private AuthorsRepository authorsRepository; @Autowired private StatisticsRepository statisticsRepository; private AlertRestClient arc = new AlertRestClient(); // The query can contain either the full name or part of the name, e.g., "Vadim Panov" or "panov" @Transactional public List<Author> search(String query) { List<Author> authors = authorsRepository.findByNameContainingIgnoreCase(query); Statistics s = statisticsRepository.findById(query).orElse(null); if (s == null) s = new Statistics(query); s.setNumbers(s.getNumbers() + 1); statisticsRepository.save(s); if (s.getNumbers() > 1000 && authors.size() > 1000) { System.out.println("too popular search with too much data, sending an alert..."); arc.send(query, s.getNumbers(), authors.size()); } return authors; } } @Entity @Data public class Author { @Id @GeneratedValue private Long id; private String name; @OneToMany(mappedBy = "author") private List<Book> books; public Author(String name) { this.name = name; } }

157

The service crashes every few hours with OutOfMemoryError. Where would you start analyzing the problem?

157

The sock problem: there are heaps of socks of three colors (red, white, black), you pick one by one — how many attempts are guaranteed to get a pair of the same color?

156

What would you like to do at a new job? What does participation in architectural decisions mean to you?

155

Tell us about yourself and your experience.

154

Provide an example of a large business task or integration that you completed entirely on your own.

153

Tell us more about how you optimized Kafka message processing and synchronous RPC calls.

152

Will a program with wallet transfers hang in a multithreading task? Why?

151

Have you ever written a BeanPostProcessor? For what purpose?

151

Are there any restrictions on indexes? What types of indexes exist (hash, B-tree) and when should they be used?

150

What will you do if you deployed something and everything crashed — alarms, unclear what is happening?

149

If the cache times out and requests start flooding the database, how can you reduce the load on the database?

149

What guarantees does a foreign key provide for data in a relational database? Is it possible to delete a parent record if there are foreign keys referencing it?

149

Read the code and identify errors ```java @Component public class AuthorSearchService { @Autowired private AuthorRepository authorRepository; @Autowired private StatisticsRepository statisticsRepository; private AlertRestClient arc = new AlertRestClient(); // The query can contain either the full name or part of it, e.g., "Vadim Pavlo" or "pavlo" @Transactional public List<Author> search(String query) { List<Author> authors = authorRepository.findByNameContainingIgnoreCase(query); Statistics s = statisticsRepository.findById(query).orElse(null); if (s == null) s = new Statistics(query); s.setNumbers(s.getNumbers() + 1); statisticsRepository.save(s); if (s.getNumbers() > 1000 && authors.size() > 1000) { System.out.println("too popular search with too much data, sending an alert..."); arc.send(query, s.getNumbers(), authors.size()); } return authors; } } @Entity @Data public class Author { @Id @GeneratedValue private Long id; private String name; @OneToMany(mappedBy = "author") private List<Book> books; public Author(String name) { this.name = name; } } ```

149

Without Hibernate, how to implement optimistic locking manually using native SQL?

148
/15