Get the latest tech news

SQL performance improvements: finding the right queries to fix


This post covers tips and tricks for performance tweaking your SQL queries by first identifying which queries need work.

Most frameworks have the concept of a "debug bar" - in the case of Laravel applications, the most widely used is the barryvdh/laravel-debugbar package that offers excellent insights. The Laravel framework can warn you when you're (potentially) causing excessive queries by throwing an exception when you're lazy loading relationships. It'll throw an exception, because for every iteration through the loop, Laravel would perform an extra query to count the comments of that specific $post instead of loading them at once.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of SQL

SQL

Photo of right queries

right queries

Related news:

News photo

Adding OR logic forced us to confront why users preferred raw SQL

News photo

Just because you can render a Doom-like in SQL doesn't mean you should

News photo

Building a DOOM-like multiplayer shooter in pure SQL