Welcome Guest, Not a member yet? Register   Sign In
Is there a better way to count query results?
#7

[eluser]mhulse[/eluser]
[quote author="Joshua Logsdon" date="1264360588"]I wanted to make a quick note that (also you would want a comma after 1):
$this->db->select('1, `container`, `margin`', FALSE);
could also just be:
$this->db->select('1', FALSE);
and that keeps your query from returning data/using bandwidth that isn't necessary.

Again, not a guru here, but if you are looking for every corner to cut, just because columns are in the WHERE clause doesn't mean they have to be in the SELECT clause. The "SELECT 1" is just to return the number 1... it could be "SELECT 'i just want to know if something exists'" to return that string if you wanted... anything just so long as the query returns something. The more you return the more bandwidth is used though... again, this may be completely negligible for your performance but is a thought.[/quote]

WOW! Great tips! Thank you Joshua!!! Smile

I definitely like the idea of using $this->db->select('1', FALSE);. Wink

And thank you for the clarification/details.

Quote:Being new to mysql, this probably falls under the "too much information" category Smile but at least you know it's out there.....

I definitely needed the detailed explanation. I am looking to learn as much as possible about CI/MVC/Models/MySql/related, so I really appreciate you taking the time to help explain things to me. Smile

Quote:if you are using a tool like phpMyAdmin it also has some query profiling ability, as in not the whole app and just the query. Or if just using MySQL you could run the query with EXPLAIN (http://dev.mysql.com/doc/refman/5.0/en/explain.html) and/or profiling (http://dev.mysql.com/tech-resources/arti...filer.html). Using tools like this you could compare queries, make sure indexes are used, etc.

More great info!! Thanks again Joshua, I owe you one! Big Grin

Have a great day!
Cheers,
Micky


Messages In This Thread
Is there a better way to count query results? - by El Forum - 01-23-2010, 10:09 PM
Is there a better way to count query results? - by El Forum - 01-23-2010, 11:27 PM
Is there a better way to count query results? - by El Forum - 01-24-2010, 12:52 AM
Is there a better way to count query results? - by El Forum - 01-24-2010, 01:20 AM
Is there a better way to count query results? - by El Forum - 01-24-2010, 01:22 AM
Is there a better way to count query results? - by El Forum - 01-24-2010, 07:16 AM
Is there a better way to count query results? - by El Forum - 01-24-2010, 03:29 PM
Is there a better way to count query results? - by El Forum - 01-25-2010, 01:23 AM
Is there a better way to count query results? - by El Forum - 01-25-2010, 01:30 AM
Is there a better way to count query results? - by El Forum - 01-25-2010, 01:48 AM
Is there a better way to count query results? - by El Forum - 01-25-2010, 04:48 AM
Is there a better way to count query results? - by El Forum - 01-25-2010, 07:52 AM
Is there a better way to count query results? - by El Forum - 01-25-2010, 11:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB