Jump to content

mysql_num_rows


LanceT

Recommended Posts

how intensive is it to use

mysql_num_rows to get a number of rows?

 

I assumed you meant "get THE number of rows", in which case it is VERY inefficient. It has to select every row from the table and return it. So in that situation COUNT(*) would be a huge performance gain.

 

Now the second time around, you show me a query that probably returns one or two rows. In that case it really wont make much of a difference, especially since you are probably going to want to know who they are.

Link to comment
https://forums.phpfreaks.com/topic/41718-mysql_num_rows/#findComment-202294
Share on other sites

how intensive is it to use

mysql_num_rows to get a number of rows?

 

I assumed you meant "get THE number of rows", in which case it is VERY inefficient. It has to select every row from the table and return it. So in that situation COUNT(*) would be a huge performance gain.

 

Now the second time around, you show me a query that probably returns one or two rows. In that case it really wont make much of a difference, especially since you are probably going to want to know who they are.

 

so my query, even if run on a 1,000,000 row table, won't take up too many resources?

 

Thanks for the input.

Link to comment
https://forums.phpfreaks.com/topic/41718-mysql_num_rows/#findComment-202298
Share on other sites

Well the tricky part is finding which records match. Its no big deal IF you've got get1 and get2 indexed. Whether you are returning the results or just counting them doesn't really matter.

 

alright well I indexed them, but also is there any loss if I index rows? If not, then why don't people just index everything?

Link to comment
https://forums.phpfreaks.com/topic/41718-mysql_num_rows/#findComment-202319
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.