Jump to content

determining if table has no record?


coder9

Recommended Posts

I was too lazy to consult the php source on this one, but if I recall, mysql_num_rows() would actually be loading a new string/array engine to actually count the number of records, but I could be woefully wrong (I guess it would do this in mysql too, but as I said, I checked neither source). I guess the only way to test it would be a speed test of each script.

Count(*) only ever returns a single field no matter how many recs are in the file. If there were 1000 recs in the file, SELECT foo pulls a 1000 foos down just so you can call num_rows().

 

"SELECT COUNT(*) FROM tbl" is optimised so it doesn't even need to read the table, it just looks it up in its internal tables.

Count(*) only ever returns a single field no matter how many recs are in the file. If there were 1000 recs in the file, SELECT foo pulls a 1000 foos down just so you can call num_rows().

 

"SELECT COUNT(*) FROM tbl" is optimised so it doesn't even need to read the table, it just looks it up in its internal tables.

 

That makes sense, you win :)

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.