Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.