General
- get only necessary data, rather than everything that can be
- sometimes is good to prepare specific object(model) for different views, rather than use standard model on each view.
- for example for list prepare custom header dto (data transfer object) object with only primitive types with calculated values from dependent entities
SQL optimizations
- use syntax 'JOIN table ON ()' rather than 'FROM tableA, tableB WHERE ...'
- use more restrictive and fast conditions first
- it's better because database in each next step have less records to verify
- use indexes
Links
https://wiki.postgresql.org/wiki/Performance_Optimization
https://wiki.postgresql.org/wiki/SlowQueryQuestions
http://explain.depesz.com/