How do we greatly optimize our MySQL database (or replace it) when using joins?

Posted by jkaz on Stack Overflow See other posts from Stack Overflow or by jkaz
Published on 2010-06-14T20:09:20Z Indexed on 2010/06/14 20:12 UTC
Read the original article Hit count: 368

Hi there,

This is the first time I'm approaching an extremely high-volume situation. This is an ad server based on MySQL. However, the query that is used incorporates a lot of JOINs and is generally just slow. (This is Rails ActiveRecord, btw)

sel = Ads.find(:all, :select => '*', :joins => "JOIN campaigns ON ads.campaign_id = campaigns.id JOIN users ON campaigns.user_id = users.id LEFT JOIN countries ON countries.campaign_id = campaigns.id LEFT JOIN keywords ON keywords.campaign_id = campaigns.id", :conditions => [flashstr + "keywords.word = ? AND ads.format = ? AND campaigns.cenabled = 1 AND (countries.country IS NULL OR countries.country = ?) AND ads.enabled = 1 AND campaigns.dailyenabled = 1 AND users.uenabled = 1", kw, format, viewer['country'][0]], :order => order, :limit => limit)

My questions:

  1. Is there an alternative database like MySQL that has JOIN support, but is much faster? (I know there's Postgre, still evaluating it.)

  2. Otherwise, would firing up a MySQL instance, loading a local database into memory and re-loading that every 5 minutes help?

  3. Otherwise, is there any way I could switch this entire operation to Redis or Cassandra, and somehow change the JOIN behavior to match the (non-JOIN-able) nature of NoSQL?

Thank you!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database