lampstax Posted July 30, 2008 Share Posted July 30, 2008 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/117440-solved-merge-engine-vs-joins-views/ Share on other sites More sharing options...
fenway Posted July 31, 2008 Share Posted July 31, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/117440-solved-merge-engine-vs-joins-views/#findComment-604802 Share on other sites More sharing options...
lampstax Posted October 29, 2008 Author Share Posted October 29, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/117440-solved-merge-engine-vs-joins-views/#findComment-677110 Share on other sites More sharing options...
fenway Posted October 30, 2008 Share Posted October 30, 2008 Yes, just modify the MERGE definition whenever you'd like. Quote Link to comment https://forums.phpfreaks.com/topic/117440-solved-merge-engine-vs-joins-views/#findComment-678531 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.