I've a problem with a script who's making sql-query on a MySQL server.
There are 106.976.536 entries in the table. It should require 5 - 6 minutes until the result is coming. At this matter of time most IRC Servers would give a ping timeout and kicks the eggdrop.
Is it possible to execute the querycommand in background while asking the MySQL server?
# This is a database queryscript above this snip is the mysql
connection declared...
proc searchmd5hash {nick uhost hand chan rest} {
global db_handle
set passtype [string tolower [lindex $rest 0]]
set hash [string tolower [lindex $rest 1]]
switch -exact -- $passtype {
brute { set sql_table "md5_hashes_brute" }
dict { set sql_table "md5_hashes_dict" }
num { set sql_table "md5_hashes_num" }
default {
putchan $chan "Bitte wählen Sie einer der folgenden Möglichkeiten: brute, dict, num"
exit 0
}
}
set sql_cmd "SELECT * FROM `$sql_table` WHERE `hash` LIKE '$hash'"
set result [mysqlquery $db_handle $sql_cmd]
# At the line above, the eggdrop hangs sometimes 5-6 minutes and mostly the IRC Server shows a timeout and kicks the eggdrop.
# How can I put this command into the background and let the eggdrop runs free until the mysql-request is answered.
if {[set row [mysqlnext $result]] != ""} {
set id [lindex $row 0]
set wert [lindex $row 1]
putchan $chan "Gesuchter Wert für den HASH\0034 $hash\003 ist:\0034 $wert\003 $id"
} else {
putchan $chan "Der Wert für den MD5 HASH\0034 $hash\003 wurde in der Datenbank\0034 md5_hashes_dict\003 leider nicht gefunden."
}
}
there is, but you can't access mysql database asynchronously (there isn't a callback mechanism that you could utilize to take care of your waiting eggdrop events); of course, you can spawn another process to handle the mysql stuff, but then you'll have to implement a synchronization mechanism
you better redesign the database, over 100 million records in a table is ridiculous, you aren't Deutsche Bank are you
As demond suggested, the easiest way is to use another process via exec or open. This can even be another tcl script, so you can still use your existing code and mysql package if you want.
On the other hand, why are you doing a wildcard search against hashes? Seems pretty weird. Since this is such a specific datatype, you could probably make your own specialized lookup functions and it would go a lot faster, especially since you only return the first result anyway.
But really... you should just try changing LIKE to =, and see how much faster it is. And make sure you have an index in your db.
heh, I didn't notice that guy is actually interfacing some kind of password cracker db
anyway, [fork] Tcl command would be useful here (I once wrote [fork] for the sole purpose of changing eggdrop PID hehe) - fetch db data in the child process, save it to file, notify parent, [exit]
you can run TCL scripts asyncronly!
open the tclsh8.4 with open, fconfigure the handle to nonblocking, dump the query part via puts and wait via fileevent readable for the resaults!
But a warning, if you are on a shared shell box your provider might cancel the contract due to much resource usage. I mean... 5min for a tcl/sql executing? wtf? Either the shell is slow as hell or you are sucking the poor machine out ^-^.