amankumar12602 / anywhereindb

Automatically exported from code.google.com/p/anywhereindb
0 stars 0 forks source link

Poor performance #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The code selects every single row in the every single table in the database 
just to see if there are any rows, before building the query to see if there 
are any rows with a matching string. Performance will be awful with a database 
of any notable size.

The performance of querying an empty table will be much more tolerable than 
selecting every single row from the entire database.

Discard these lines:
                        //@abstract querry bliding of each table
                        $sql = 'select * from '.$tables[$i]['Tables_in_'.$dbname];
                        $res = mysql_query($sql);

                        if(mysql_affected_rows()>0)

If you absolutely have to check if there are rows first, look in the table 
status, or at least just SELECT COUNT(*) FROM table;

mysql_affected_rows() is the wrong function to use here anyway; the PHP manual 
says to use mysql_num_rows() after a SELECT statement. It does work in modern 
libraries, but you should not rely on non-documented behavior.

Original issue reported on code.google.com by sno...@gmail.com on 2 Oct 2010 at 2:03

GoogleCodeExporter commented 8 years ago
Issue Fixed! 
thank you for pointing out the problem. 

Original comment by happ...@gmail.com on 22 Dec 2010 at 4:48