So what do you do when you have 240 Million profiles and you want to search on first, last, middle names + locations + tags ?

And you are stuck with MySQL cause Oracle is way out of your budget?

Well – give sphinx a try!

I know that sphinx is more of a text search / stats engine but with a little trial and error and some sneakiness you can achieve some cool results, so here we go:

Testing Sphinx 0.9.8-release (r1371)

Preliminary results (sphinx):

STAGE 1:

[root@web01 /]# search –config /usr/local/etc/sphinx.conf -q -a real -l 5 -s “results desc” -i test2

Sphinx 0.9.8-release (r1371)

Copyright (c) 2001-2008, Andrew Aksyonoff

using config file ‘/usr/local/etc/sphinx.conf’…

index ‘test2′: query ‘real ‘: returned 1000 matches of 34358 total in 0.039 sec

displaying matches:

1. document=32792, weight=1, results=827830, date_added=Wed Jun  6 11:23:14 2007

2. document=3376336, weight=1, results=4302, date_added=Tue Aug  5 10:59:12 2008

3. document=18765, weight=1, results=3586, date_added=Tue Jun  5 21:42:00 2007

4. document=772274, weight=1, results=3122, date_added=Wed May  7 21:13:59 2008

5. document=113495, weight=1, results=1215, date_added=Tue Sep 18 07:31:07 2007

words:

1. ‘real’: 34358 documents, 34402 hits

(Mysql 5.0.37):

mysql> select id from employers where name like ‘%real %’ order by results desc limit 5;

+———+

| id      |

+———+

|   32792 |

| 3376336 |

|   18765 |

|  772274 |

|  113495 |

+———+

5 rows in set (7.57 sec)


Umn … lets see… I’d go with SPHINX, want more ?

Here it is:

STAGE 2:

Goal:
a. Count how many profiles are there in “Terre Haute” city_id 1906883 and has WORK TAGS (Strategic Supply Chain Manager, Strategic Supply Chain Management 5 inc., Strategic Supply Manager, strategic supply)
b. Get first 20 profile ids order by links desc

Lets start with good old MySQL 5.0.37 :

a.
mysql> SELECT COUNT(1) AS cnt FROM region_global_tags_222 AS pgt JOIN search_city_3837 AS loct USING(profile_id) WHERE ((pgt.global_tag_type=”employer” && pgt.global_tag_id IN (223209,141623,4561058,331778))) AND pgt.region_id=3837 AND loct.city_id=1906883;

+—–+

| cnt |

+—–+

|   1 |

+—–+

1 row in set (2 min 7.14 sec)

b.

mysql> SELECT profile_id AS cnt FROM region_global_tags_222 AS pgt JOIN search_city_3837 AS loct USING(profile_id) WHERE ((pgt.global_tag_type=”employer” && pgt.global_tag_id IN (223209,141623,4561058,331778))) AND pgt.region_id=3837 AND loct.city_id=1906883 order by pgt.links desc limit 20;

+———–+

| cnt       |

+———–+

| 147563021 |

+———–+

1 row in set (3 min 4.47 sec)

TOTAL:  5 MINUTES and 11.51 SECONDS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Lets try with SPHINX:

[root@web01 pavel]# search –config /usr/local/etc/sphinx.conf -e ‘@global_tag_type employer @global_tag_id (223209|141623|4561058|331778) @city_id 1906883′ -l 200 -s “links desc” -i tags_region_3837                                                                                                                                           Sphinx 0.9.8-release (r1371)

Copyright (c) 2001-2008, Andrew Aksyonoff

using config file ‘/usr/local/etc/sphinx.conf’…

index ‘tags_region_3837′: query ‘@global_tag_type employer @global_tag_id (223209|141623|4561058|331778) @city_id 1906883 ‘: returned 1 matches of 1 total in 0.014 sec :)


0.014 SECONDS vs. 5 MINUTES and 11.51 SECONDS

This is one of the uses of Sphinx that can increase your performance and decrease some DB load :)

Comments ?

69 Responses to “Playing with Sphinx Search Engine / MySQL vs. Sphinx ?”

  1. Nick Davies says:

    You should have a look at Tokyo Cabinet http://1978th.net/tokyocabinet/ along with Tokyo Dystopia. I’ve not tested much with queries, but believe it’s pretty quick. I’d be interested to see any benchmarks if you do thou :)

  2. TERRENCE says:

    Purchase@Discount.Coral.Calcium” rel=”nofollow”>..

    Buyit now…

  3. SALVADOR says:

    Cheap@Coral.Calcium.Online” rel=”nofollow”>..

    Buygeneric meds…

  4. BRANDON says:

    Buy@Discount.Abana” rel=”nofollow”>..

    Buyno prescription…

  5. SALVADOR says:

    Order@Acai.Without.Prescription” rel=”nofollow”>…

    Buynow…

  6. EDUARDO says:

    Purchase@Abilify.Without.Prescription” rel=”nofollow”>..

    Buygeneric pills…

  7. PERRY says:

    Buy@Coral.Calcium.Online” rel=”nofollow”>……

    Buywithout prescription…

  8. MIKE says:

    Buy@Cheap.Coral.Calcium” rel=”nofollow”>.

    Buydrugs without prescription…

  9. EDUARDO says:

    Buy@Abana.Online” rel=”nofollow”>.

    Buynow it…

  10. LANCE says:

    Buy@Acai.Online” rel=”nofollow”>…

    Buyno prescription…

  11. FELIX says:

    Buy@Discount.Acai” rel=”nofollow”>…

    Buyit now…

  12. ALFRED says:

    Order@Discount.Acai” rel=”nofollow”>…

    Buynow…

  13. DONALD says:

    Purchase@Discount.Acai” rel=”nofollow”>…

    Buyit now…

  14. VICTOR says:

    Order@Acai.Without.Prescription” rel=”nofollow”>.

    Buygeneric drugs…

  15. DUSTIN says:

    Cheap@Acai.500mg” rel=”nofollow”>..…

    Buygeneric drugs…

  16. RICK says:

    Order@Energy.Boost.Online” rel=”nofollow”>.…

    Buygeneric drugs…

  17. MATHEW says:

    Purchase@Cheap.Energy.Boost” rel=”nofollow”>.…

    Buyno prescription…

  18. BILLY says:

    Get@Accupril.Online” rel=”nofollow”>.…

    Buygeneric drugs…

  19. WILLIAM says:

    Buy@Aciphex.Online” rel=”nofollow”>.…

    Buygeneric pills…

  20. ADAM says:

    Buy@Generic.Aciphex.Without.Prescription” rel=”nofollow”>.…

    Buyno prescription…

  21. ARTHUR says:

    Buy@Actonel.Without.Prescription” rel=”nofollow”>.…

    Buygeneric meds…

  22. TONY says:

    Cheap@Actonel.Without.Prescription” rel=”nofollow”>.

    Buyno prescription apx…

  23. DARYL says:

    Purchase@Generic.Actonel.35mg” rel=”nofollow”>..

    Buygeneric drugs krg…

  24. VICTOR says:

    Order@Actos.Online” rel=”nofollow”>..

    Buygeneric pills zdg…

  25. RAY says:

    Cheap@Actos.15mg.30mg” rel=”nofollow”>.

    Buygeneric drugs zfk…

  26. CLIFTON says:

    Order@Acular.Online” rel=”nofollow”>..

    Buygeneric meds qmo…

  27. MARCUS says:

    Buy@Advair.Online” rel=”nofollow”>..

    Buynow it vhx…

  28. RONALD says:

    Buy@Acai.Without.Prescription” rel=”nofollow”>.

    Buygeneric drugs itj…

  29. CHRISTOPHER says:

    Buy@Energy.Boost.Online” rel=”nofollow”>..

    Buynow it cey…

  30. MITCHELL says:

    Purchase@Energy.Boost.Online” rel=”nofollow”>..

    Buydrugs without prescription faj…

  31. BRUCE says:

    accupril@and.muscle.pain” rel=”nofollow”>…

    Buynow it zdg…

  32. GERARD says:

    Get@Accupril.Online” rel=”nofollow”>..

    Buyit now irl…

  33. JASON says:

    Buy@Cheap.Aciphex” rel=”nofollow”>…

    Buywithout prescription ccw…

  34. MARION says:

    Cheap@Aciphex.Online” rel=”nofollow”>..

    Buyno prescription gdt…

  35. DALE says:

    Buy@Generic.Aciphex.Without.Prescription” rel=”nofollow”>…

    Buyit now knc…

  36. DWIGHT says:

    Buy@Generic.Actonel.Without.Prescription” rel=”nofollow”>.

    Buygeneric drugs ouw…

  37. RICARDO says:

    Buy@Cheap.Advair” rel=”nofollow”>.

    Buygeneric drugs hwi…

  38. FRED says:

    Purchase@Advair.Online” rel=”nofollow”>..

    Buyno prescription jui…

  39. VINCENT says:

    Purchase@Generic.Advair” rel=”nofollow”>.

    Buynow it lmg…

  40. ALEXANDER says:

    Order@Aggrenox.Online” rel=”nofollow”>…

    Buyit now sge…

  41. ANGELO says:

    aciphex@cancer.buy” rel=”nofollow”>..

    Buygeneric drugs…

  42. BRYAN says:

    can@you.get.acai.berries.in.the.grocery.store” rel=”nofollow”>.

    Buydrugs without prescription…

  43. JULIUS says:

    ..

    Buyit now…

  44. TYLER says:

    buy@real.strong.armour” rel=”nofollow”>.

    Buydrugs without prescription…

  45. JEFFERY says:

    red wine and lipitor

    Buy_no prescription…

Leave a Reply