Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there such thing as a query being too big?

I don't have too much experience with SQL. Most of the queries I have written have been very small. Whenever I see a very large query, I always kinda assume it needs to be optimized. But is this true? or is there situations where really large queries are just whats needed?

BTW when I say large queries I mean queries that exceed 1000+ chars

like image 604
JD Isaacks Avatar asked Jan 14 '10 18:01

JD Isaacks


1 Answers

Yes, any statement, method, or even query can be "too big".

The problem, is actually defining what too big really is.

If you can't sit down and figure out what the query does in a relatively short amount of time, it's probably best to break it up into smaller chunks.

I always like to look at things from a maintenance standpoint. If the query is hard to understand now, what if you have to debug something in it?

Just because you see a large query, doesn't mean it needs to be changed or optimized, but if it's too complicated for its own good, then you might want to consider refactoring.

like image 108
Robert Greiner Avatar answered Sep 27 '22 17:09

Robert Greiner