Optimize Django Query Performance by combining Select Related and Prefetch Related

Introduction When building a Django application, one of the key challenges developers face is optimizing database query performance. Django provides two tools,select_related and prefetch_related, that reduce the number of database queries, and increase the performance of your application. This blog post explores the power of these two methods and how to combine them to maximize your application’s query performance. My team at PixieBrix implemented these techniques and have seen a significant improvement in query performance and customer satisfaction....

May 13, 2023 · 3 min · Johnny Metz

Free up disk space with Docker prune

Docker is a platform for developing, shipping and running applications in isolated, lightweight and portable containers. It is a critical part of a developer’s toolbelt and one I use just about everyday. Docker can consume a large amount of disk space. Per the Docker documentation: Docker takes a conservative approach to cleaning up unused objects (often referred to as “garbage collection”), such as images, containers, volumes, and networks: these objects are generally not removed unless you explicitly ask Docker to do so....

January 21, 2023 · 4 min · Johnny Metz

[Cross-Post] Django performance: Sort by a Custom Order

See the post here: Sort a Django Queryset by a Custom Order

January 2, 2023 · 1 min · Johnny Metz

Disable a direct push to GitHub main branch

On a development team, you never want to push directly to the main branch. Instead, you want to require changes to be made through pull requests so they can be properly reviewed by other developers. Some developers, including myself, occasionally forget to push to a new branch so I like to have an automated check to prevent this mistake. Here are two methods to block direct pushes to the GitHub main branch....

December 29, 2022 · 2 min · Johnny Metz

[Cross-Post] Enforce Best Dockerfile Practices with Hadolint

See the post here: Using Hadolint, a Dockerfile linter, To Enforce Best Practices

March 17, 2022 · 1 min · Johnny Metz