nekonezinu Posted May 31, 2008 Author Report Share Posted May 31, 2008 Man tomēr nekā nesanāk atrisināt šo problēmu ar datu skaitīšanu! Uztaisiju lai katru titles vardu ielik savā ierakstā un tad skaita, bet tas ierakstu skaitīšanu vispar nepaātrināja !! Link to comment Share on other sites More sharing options...
bubu Posted May 31, 2008 Report Share Posted May 31, 2008 Indeksi ir salikti? EXPLAIN komandu māki pielietot? Link to comment Share on other sites More sharing options...
nekonezinu Posted May 31, 2008 Author Report Share Posted May 31, 2008 Izmēģināju visus indexu tipus, bet skaitīšana uz dažiem vārdiem aizņem 0,003s bet uz dažiem 300s vai ari vispār saskaita 0 kaut arī ir ieraksti, vai ari paiet kādas 300s un parāda 0 ierakstu (ja vārda nav), bet es domāju , ka tik ilgi nevajag skaitīt to kā nav! Nezinu explain komandu! Link to comment Share on other sites More sharing options...
Kristabs Posted May 31, 2008 Report Share Posted May 31, 2008 ieej mysql un izpildi > Explain Select 1 Šis pastāstīs vai lieto indeksus un kurus, kā arī izpildes laiku, varēsi optimizēt. Link to comment Share on other sites More sharing options...
nekonezinu Posted May 31, 2008 Author Report Share Posted May 31, 2008 Kur ieiet? Link to comment Share on other sites More sharing options...
bubu Posted May 31, 2008 Report Share Posted May 31, 2008 Pirmkārt, ieiet manuālī - http://dev.mysql.com/doc/refman/5.0/en/using-explain.html Otrkārt, ieiet jebkurā mysql klientā (kautvai komandrindas mysql.exe) un izpildīt kveriju EXPLAIN SELECT tavs_kverijs. Un no parādītajiem rezultātiem secināt, kādus indeksus šis taisās lietot vai nē. Indeksus nevajag uz bobi likt. Vajag no izpildāmā kverija secināt precīzi kādus vajadzēs, salikt tos, un ar explain pārbaudīt vai tie izmantojas. Link to comment Share on other sites More sharing options...
nekonezinu Posted June 1, 2008 Author Report Share Posted June 1, 2008 mysql_query("EXPLAIN SELECT COUNT(*) FROM vardi WHERE vards ='$s'"); uz php man neko nerāda Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2008 Report Share Posted June 1, 2008 doh, loģiski. Kur gan tev ir mysql_fetch_row/array ? Link to comment Share on other sites More sharing options...
nekonezinu Posted June 1, 2008 Author Report Share Posted June 1, 2008 mysql_query("EXPLAIN SELECT COUNT(*) FROM vardi WHERE vards ='$s'"); while ($col = mysql_fetch_assoc($aa)){ echo $col['vards'];} } nekaa Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2008 Report Share Posted June 1, 2008 EXPLAIN tev neatgriezīs paša kverija rezultātus. Tak atver manuāli un palasi lūdzams, ko tas atgriež. echo $col['vards'] vietā ieraksti print_r($col); Un kas tev ir $aa mainīgais, m? Slikti, ka tu neprogrammē ar error_reporting = E_ALL un display_errors = 1. Link to comment Share on other sites More sharing options...
nekonezinu Posted June 1, 2008 Author Report Share Posted June 1, 2008 Array ( [id] => 1 [select_type] => SIMPLE [table] => vardi [type] => ref [possible_keys] => vards [key] => vards [key_len] => 20 [ref] => const [rows] => 2959 [Extra] => Using where; Using index ) ) for "dvdrip" Array ( [id] => 1 [select_type] => SIMPLE [table] => vardi [type] => ref [possible_keys] => vards [key] => vards [key_len] => 20 [ref] => const [rows] => 107 [Extra] => Using where; Using index ) ) for "russia" ko pēc ši var secināt? Ka indexi strādā, bet bez jeegas? Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2008 Report Share Posted June 1, 2008 Jā, indeksi strādā. Šādam kverijam vajadzētu izpildīties ļoti ātri, arī uz daudziem tūkstošiem rindu. Kāds izskatās tavs indekss uz vards kolonnu? Link to comment Share on other sites More sharing options...
nekonezinu Posted June 1, 2008 Author Report Share Posted June 1, 2008 Tagad ir unique in skaita cik tas vārds atkārtojās.. Link to comment Share on other sites More sharing options...
marrtins Posted June 1, 2008 Report Share Posted June 1, 2008 300 sekundes? oho... parādi savu tabulu struktūru ar visiem indexiem Link to comment Share on other sites More sharing options...
nekonezinu Posted June 2, 2008 Author Report Share Posted June 2, 2008 Tagad ir Keyname Type Cardinality Action Field vards_in UNIQUE 27124 Edit Drop vards Kverija $aa = mysql_query("SELECT * FROM vardi WHERE vards LIKE'$s%' ORDER by vards ASC "); while ($col = mysql_fetch_assoc($aa)){ echo $col['skaits']; } Meklējamais vārds | Laiks dvdrip 0.0659289360046 music 0.693972826004 war 0.223150014877 Latvia 88.6878938675 - nez kāpēc ilgi Antartic 71.9599230289 -tāda vārda nav, bet lēni to noskaidroja Link to comment Share on other sites More sharing options...
Recommended Posts