Jump to content

[SOLVED] MERGE engine vs { joins | views }


lampstax

Recommended Posts

Sorry if this has been asked before, but searching for 'MERGE' on this forum returns too many irrelevant results.

 

Can someone tell me when you would use the MERGE storage engine vs joins or a view ? 

 

I read the MySQL book, and the example they gave, is if you had a separate table for countries each continent, you can create a MERGE table and get all the countries for all continents.

 

From what I know, I can achieve this result by creating a view, or a complex join.

 

So what would be the benefit to using MERGE vs joins and/or views ?

 

 

Link to comment
Share on other sites

MERGE just makes it easier to not have to update code to deal with "moving" records... for example, you can have a MERGE table called "record_archive", which contains all "old" rows  from "record" table after a certain date.  But, using MERGE, that record_archive table could actually be 10 underlying tables, one for each of the past 10 years.  When you add a new year, you don't have to do anything to the codebase -- you just change the MERGE table definition.  Make sense?

Link to comment
Share on other sites

  • 2 months later...

Yeah.  That makes sense.  If it was a join or view .. I would have to add the new table into the join .. simple enough .. but it could make a huge although simple sql statement .. and i would have to make that change everywhere .. with Merge, i can just modify the merge table definition once a year!

 

thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.