0

I am using thinking_sphinx in Rails. As far as I know, Sphinx is used for full text search. Let's say I have these queries:

keyword
country
sort order

I use Sphinx for all the search above. However, when I am querying without keyword, but just country and sort order only, is it a better to use just normal query in MySQL instead of using Sphinx?

In other words, should Sphinx be used only when keyword is searched?

Looking at overall performance and speed.

Victor
  • 13,010
  • 18
  • 83
  • 146

3 Answers3

3

Not to sound snarky, but does performance really matter?

If you're building an application which will only be used by a handful of users within an organization, then you can probably dismiss the performance benefits of using one method over the other and focus instead on simplicity in your code.

On the other hand, if your application is accessed by a large number of users on the interwebz and you really need to focus on being performant, then you should follow @barryhunter's advice above and benchmark to determine the best approach in a given circumstance.

P.S. Don't optimize before you need to. Fight with all your heart to keep code out of your code.

samullen
  • 2,380
  • 2
  • 17
  • 18
2

Benchmark! Benchmark! Benchmark!

Ie test it yourself. The exact performance will vary depending on the exact data, and perhaps even the relative perofrmance of your sphinx and mysql servers.

barryhunter
  • 20,886
  • 3
  • 30
  • 43
1

Sphinx will offer killer-speeds over MySQL when searching by a text string and MySQL will probably be faster when searching by a numerical key.

So, assuming that both "country" and "sort order" can be indexed using a numerical index in MySQL, it will be better to use Sphinx only with "keyword" and for the other two - MySQL normal query.

However, benchmarks won't hurt, as barryhunter suggested ;)

guntars
  • 320
  • 2
  • 6