FWIW, my opinion is that you always start with the database, especially an RDBMS, to solve your problem. Databases have some pretty advanced programming constructs, and advanced algorithms that are available to you via a language as simple as SQL.
And when it (the database) cannot serve your needs in terms of performance anymore, then you must choose a domain-specific product dedicated to solve the you challenges.
> premature optimization is the root of all evil.