TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Does Count(*) consume more memory? (http://www.talkphp.com/absolute-beginners/3799-does-count-consume-more-memory.html)

kokjj87 12-24-2008 09:07 AM

Does Count(*) consume more memory?
 
Just wondering does of both of them consume the same amount of memory??... let say i have 5 column in the table.

PHP Code:

Select count(*) from table

Select count
(idfrom table 


Village Idiot 12-24-2008 03:28 PM

Although I cant say for sure, but count(*) would in theory take more since it has to find what all the columns are and count them.

geo353 12-24-2008 03:49 PM

i think they would both use about the same seeing as whichever you use they both just count the nunber of rows.

Village Idiot 12-24-2008 03:51 PM

Quote:

Originally Posted by geo353 (Post 20692)
i think they would both use about the same seeing as whichever you use they both just count the nunber of rows.

But the wildcard key gives SQL more to do, SELECT * FROM table is almost always slower than SELECT id,username,othercolumn1,ect FROM table

geo353 12-24-2008 03:59 PM

i understand that but, and i may be wrong, count is optimized for speed and regardless of the selected column the number of rows will always be the same. so i dont see why this should affect the speed. i might be wrong though.

Village Idiot 12-24-2008 04:01 PM

Saying * still makes it resolve for every row in the table, not a giant difference, but using * will be slower.

sketchMedia 12-24-2008 05:01 PM

Have a read of this, its very interesting.
http://www.mysqlperformanceblog.com/...t-vs-countcol/


All times are GMT. The time now is 12:15 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0