Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6728417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:10:04+00:00 2026-05-26T10:10:04+00:00

I’m having some performance issues with MySQL database due to it’s normalization. Most of

  • 0

I’m having some performance issues with MySQL database due to it’s normalization.

Most of my applications that uses a database needs to do some heavy nested queries, which in my case takes a lot of time. Queries can take up 2 seconds to run, with indexes. Without indexes about 45 seconds.

A solution I came a cross a few month back was to use a faster more linear document based database, in my case Solr, as a primary database. As soon as something was changed in the MySQL database, Solr was notified.

This worked really great. All queries using the Solr database only took about 3ms.

The numbers looks good, but I’m having some problems.

  • Huge database

The MySQL database is about 200mb, the Solr db contains about 1.4Gb of data.
Each time I need to change a table/column the database need to be reindexed, which in this example took over 12 hours.

  • Difficult to render both a Solr object and a Active Record (MySQL) object without getting wet.

The view is relying on a certain object. It doesn’t care if the object it self is an Active Record object or an Solr object, as long as it can call a set of attributes on the it.

Like this.

# Controller
@song = Song.first

# View
@song.artist.urls.first.service.name

The problem in my case is that the data being returned from Solr is flat like this.

{
  id: 123,
  song: "Waterloo",
  artist: "ABBA",
  service_name: "Groveshark",
  urls: ["url1", "url2", "url3"]
}

This forces me to build an active record object that can be passed to the view.

My question

Is there a better way to solve the problem?
Some kind of super duper fast primary read only database that can handle complex queries fast would be nice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:10:04+00:00Added an answer on May 26, 2026 at 10:10 am

    Solr individual fields update

    About reindexing all on schema change: Solr does not support updating individual fields yet, but there is a JIRA issue about this that’s still unresolved. However, how many times do you change schema?

    MongoDB

    If you can live without a RDBMS (without joins, schema, transactions, foreign key constrains), a document-based DB like MongoDB,
    or CouchDB would be a perfect fit. (here is a good comparison between them )

    Why use MongoBD:

    • data is in native format (you can use an ORM mapper like Mongoid directly in the views, so you don’t need to adapt your records as you do with Solr)
    • dynamic queries
    • very good performance on non-full text search queries
    • schema-less (no need for migrations)
    • build-in, easy to setup replication

    Why use SOLR:

    • advanced, very performant full-text search

    Why use MySQL

    • joins, constrains, transactions

    Solutions

    So, the solutions (combinations) would be:

    1. Use MongoDB + Solr

      • but you would still need to reindex all on schema change
    2. Use only MongoDB

      • but drop support for advanced full-text search
    3. Use MySQL in a master-slave configuration, and balance reads from slave(s) (using a plugin like octupus) + Solr

      • setup complexity
    4. Keep current setup, denormalize data in MySQL

      • messy

    Solr reindexing slowness

    The MySQL database is about 200mb, the Solr db contains about 1.4Gb of
    data. Each time I need to change a table/column the database need to
    be reindexed, which in this example took over 12 hours.

    Reindexing 200MB DB in Solr SHOULD NOT take 12 hours! Most probably you have also other issues like:

    MySQL:

    • n+1 issue
    • indexes

    SOLR:

    • commit after each request – this is the default setup is you use a plugin like sunspot, but it’s a perf killer for production

    From http://outoftime.github.com/pivotal-sunspot-presentation.html:

    • By default, Sunspot::Rails commits at the end of every request
      that updates the Solr index. Turn that off.

      • Use Solr’s autoCommit
        functionality. That’s configured in solr/conf/solrconfig.xml
      • Be
        glad for assumed inconsistency. Don’t use search where results need to
        be up-to-the-second.
    • other setup issues (http://wiki.apache.org/solr/SolrPerformanceFactors#Indexing_Performance)

    Look at the logs for more details

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
I have a reasonable size flat file database of text documents mostly saved in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.