News for hackers. Stuff that matters.
Re:How not to structure database-backed web apps: performanc... by vidarh on Thursday June 28, 2018 @10:45AM (#17417241)
I'd think you could do warnings on this simply by processing a log of the queries, looking for query patterns that match common poor code patterns.

E.g.

    SELECT id FROM table [some conditions]
followed by a number of

   SELECT * FROM table WHERE id = ...
 
is one example of a anti-pattern that suggests that someone is doing an overly simplistic query followed by a loop. Similar with signs of triggering loading of related objects instead of a JOIN.

Doing it on the emitted SQL would also make it quite easy to make it reasonably ORM agnostic - it doesn't need to be perfect, after all, so doing relatively crude pattern matching ought to be able to find at least the more basic problems.

There are no comments on this comment yet.