Posted by C. on 12/12/06 13:05
Cleverbum@hotmail.com wrote:
> Toby Inkster wrote:
> > Rik wrote:
> >
> > > Indeed, or possibly check it first:
> > > $searchstring = md5(//something);
> > > $result = mysql_query("SELECT `textmd5` FROM `logs_full` WHERE `textmd5` =
> > > '{$searchstring}'");
> > > if(mysql_num_rows($result) < 1){
> > > //not in table logic..
> > > } else {
> > > //is in table logic..
> > > }
> >
> > As the OP said, he needs to check "hundreds of thousands" of md5 strings
> > -- using an SQL call for each one will slow him down.
>
> Hit the nail on the head.
>
PHP arrays are not particularly fast / efficient - particularly when
they get big. The fastest way to resolve two large lists like this is
to keep the "hundreds of thousands" of needles in a table as well as
the haystack and join the two in an SQL query (rDBMS are designed
specifically to do this kind of thing).
C.
[Back to original message]
|