diff --git a/html/ajax_rulesuggest.php b/html/ajax_rulesuggest.php
index 7abd574e13..b4f410f4a8 100644
--- a/html/ajax_rulesuggest.php
+++ b/html/ajax_rulesuggest.php
@@ -80,13 +80,9 @@ if( isset($_GET['term'],$_GET['device_id']) ) {
$chk = $memcache->get('rule-suggest-toplvl');
}
if( !(sizeof($chk) > 0) || $chk === false ) {
- $tmp = dbFetchRows('SHOW TABLES');
+ $tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
foreach( $tmp as $tst ) {
- $tbl = array_shift($tst);
- $chhk = dbFetchRows('SELECT device_id FROM '.$tbl.' LIMIT 1');
- if( isset($chhk[0]['device_id']) ) {
- $chk[] = $tbl.'.';
- }
+ $chk[] = $tst['TABLE_NAME'].'.';
}
}
}