chasethemetal Posted January 23, 2013 Share Posted January 23, 2013 Hey all! What option do you think will scale better? To have 1 big select statement joining columns. Or multiple small queries to retreive the same information. Let me illustrate what I mean exaclty. Table2 and Table3 could have millions of records while, Table1 would only have thousands. The big select with Joining SELECT table1.uri, table1.name, table2.random1, table2.random2, table3.something1, table3.something2FROM table1, table2, table3WHERE table1.id = 1 AND table2.id = 1 AND table3.id = 1 Multi small queries SELECT uri, name FROM table1 WHERE id = 1SELECT random1, random2 FROM table2 WHERE id = 1SELECT something1, something2 FROM table3 WHERE id = 1 Thanks! Link to comment Share on other sites More sharing options...
boen_robot Posted January 24, 2013 Share Posted January 24, 2013 One bigger query is always preferable. However, you should use appropriate LIMIT clauses whenever that makes sense, so that each subquery can be as fast as possible and deliver only what's needed.So for example, if you're only displaying the first 100 records, adding "LIMIT 100" at the very end is not just a nice to have, but a must. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now