MySQL: InnoDB or MyISAM - what is better for Yii
#1
Posted 13 December 2010 - 04:23 PM
As a continuity to this post. If someone have some spare time, please share with me (and others) your feelings about using InnoDB and MyISAM storage engines in MySQL? Dose having (or not) support for transactions (as in mentioned post) is the only difference? Which one is faster or serves better for Yii, in your opinion? What are factors that Yii developer should take into account, when selecting storage engine for MySQL DBMS?
Thanks in advance for any response!
#2
Posted 13 December 2010 - 06:32 PM
Referential integrity should IMO be handled by the database.
But, as I found out a small week ago, not all hosts (my new blog as a matter of fact) does not support InnoDb..
So I need to write all that jazz code myself (and I hate that): delete all dependent stuff when a post is deleted..
I know that we shouldn't rely on the database taking care of business, but that's what it's there for, isn't it?
I know that people stay that MyISAM is faster, but I would prefer InnoDb any day.
Maybe because I don't know better.

I'd love to hear what others (and more experienced people) have to say.
#3
Posted 14 December 2010 - 03:42 AM
jacmoe, on 13 December 2010 - 06:32 PM, said:
Well, I'm for sure not more experienced developer, but I agree with those other, you cite here. I also heard many different, not related to each other (or particular project) people saying that lending business logic partially or in whole to database is not too wise idea, as in some way you are using control over it. Me personally, even if I would decide to InnoDB I would still stay on "older" MyISAM-like approach, where all the logic is handled by Yii, in methods like beforeSave for example.
#4
Posted 14 December 2010 - 04:00 AM
jacmoe, on 13 December 2010 - 06:32 PM, said:
I see it exactly the other way round: A perfect DBMS should be a system that ensures that our data is always in a consistent state. So if our code has a bug, it still should be impossible to leave the DB in an inconsistent state. If you think that's bad, then consider the fact, that a huge part of business rules is already defined in DB: The column data types are the basis for our validation rules. In the same way the DB will never allow to save a string to a INT column, it should not allow to e.g. add a record with a non existant foreign key id.
#5
Posted 14 December 2010 - 04:48 AM
#6
Posted 14 December 2010 - 08:19 AM
mdomba, on 14 December 2010 - 04:48 AM, said:
Then, what is use of methods like beforeSave()? :]
Plus, I met two or three situations in a different company where it was stated that even best developer will never be the best SQL server admin (and vice versa). If following this thinking, placing business logic in DB produces additional time / problems on cooperation point.
But, this is quite of topic. I agree with you. You made me change my mind. Thank you for all your replies.
#7
Posted 14 December 2010 - 08:28 AM
Anyway in the best scenario you have a good database developer and a good programmer that works together

#8
Posted 16 December 2010 - 01:12 PM
mdomba, on 14 December 2010 - 08:28 AM, said:
Anyway in the best scenario you have a good database developer and a good programmer that works together

There are many uses to the before/afterSave() methods aside from data validation. As far as possible constraints should be set up in the database, every web developer needs to have a good grasp of at least basic database management. Check out these interesting articles on the subject:
http://blogs.sitepoi...table-pros-con/
http://blogs.sitepoi...-php-emulation/
#9
Posted 16 December 2010 - 05:47 PM
Bala, on 16 December 2010 - 01:12 PM, said:
Hm... strange (is it?)... I'm getting error saying that Firefox is unable to locate blogs.sitepoint.com server. Tested on 2010-12-16, 23:40 GMT+1.
#10
Posted 16 December 2010 - 06:06 PM
Nevertheless, and apart from Rent a car systems, I never developed bigger systems than that, which required more DB performance considerations.
Once I was working in Singapure for www.sprice.com asia. I developed the front end interface experience (javascript) for flights and hotels but our DB was not mysql. So I never had the chance to evaluate its efficiency in huge systems.

#11
Posted 17 December 2010 - 04:07 AM

#12
Posted 17 December 2010 - 04:59 AM
Mike, on 17 December 2010 - 04:07 AM, said:

Mike! That is a wonderful idea! :] I would never figured it out, if you wouldn't tell me the secret! :}
Seriously! I started this post not to take any numbers or benchmarks because - as you correctly assumed - this can be done via Google. I wanted to gather some other developers opinions and ideas on this subject, as such response may be (and many times - is) much, much more valuable than numbers.
Take my beloved (yeak! :/) Oracle as an example. If you dig through whole bunch of results, benchmarks and numbers you may made yourself thinking that if properly configured, run on correctly setup hardware and managed by an experienced administrator, this is the fastest RDBMS among all available now on the market (forgive me if my opinion is based on wrong assumptions, this is only an example). But even so, my personal coding practice in Yii is that this is the worst RDBMS to be choose for Yii development and I wouldn't either use it or advice someone else to use it, if I wouldn't be forced to do so, even if someone would gave me licensee for it for free.
#13
Posted 17 December 2010 - 05:08 AM
#14
Posted 17 December 2010 - 05:21 AM

And Trejder: benchmark !== numbers
#15
Posted 30 October 2011 - 04:27 AM
#16
Posted 30 October 2011 - 06:11 AM
itpg, on 30 October 2011 - 04:27 AM, said:
Thanks for your vote.
As I stated (or not?) I'm rather DB newbie. So, I'm just a little bit surprised, of what you've just wrote. I thought that an ability of defining relation logic directly in database (InnoDB) should speed up data access in comparison to situation, where such logic is defined on code side. Especially for a large datasets, with many relations. Am I wrong?
#17
Posted 30 October 2011 - 06:51 AM
#18
Posted 15 November 2011 - 11:39 AM
It depends on the project's requirements. If you have lots of insertions and updates and/or you need data integrity, you should probably go with InnoDb as it supports transactions and all sorts of other neat stuff. MyIsam can get quite slow for these operations as it needs to update indexes each time.
If your project requires only a few updates and inserts, but lots of select operations (e.g. a heavy traffic website could be such a scenario: Let's say 1 blog post per day and a bunch of comments, but hundreds of thousands of visitors) you might want to think about MyIsam. Since the indexes are not updated very often, there's no penalty there but the read operations will be fast.
On the other hand, you can also cache stuff to minimize database access making InnoDb also interesting for these kind of projects.
#19
Posted 16 November 2011 - 10:09 AM
InnoDB is a default engine in MySQL as of 5.5 (or even earlier). Why? Because MyISAM is outdated, it's not being developed and if something goes wrong most of the MyISAM tables end in messed up state - it's just not fault tolerant. I'm not even mentioning that table can corrupt during the normal working process.
By all means, InnoDB is really superior. The only task MyISAM is good for is for storing logs witch are not important - write speeds are better (no transactions, isolation levels and foreign keys to process) and you can compress those tables.
#20
Posted 16 November 2011 - 10:15 AM
Psih, on 16 November 2011 - 10:09 AM, said:
Erm, I beg to differ. If that is really your use case, you might want to have a look at the Archive storage engine. MyISAM tables can be compressed, yes. But if you do so, you can no longer write to them.