Live data from Hacker News

PostgreSQL vs MySQL: an apples to oranges comparison

ledgersmbdev.blogspot.co.uk

31–40 of 71 posts

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#31
post #10

I think it really depends on the type of apps you write. If you write small - medium rails apps, then the db is usually just dumb storage and if you are careful to use the ORM properly, then DBs are just plug and play. If your app is larger and you need more features, then you look more deeply into the features of each in which, most of the time, POSTGRES is the clear winner.

On top of that, if all you are doing is relatively simple persistence, the sql_mode and plugin table model can be actually very useful even though these get in the way in some other environments.

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#32
post #30

Earlier quoted context omitted.

Author here. Mysql - Model is in your code. PostgreSQL - Model is at least partially in your database. Also your code can be at least partly in your database which is what makes this possible. There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. I didn't say that. However if you read the entire O/R modelling series you will see in PostgreSQL it is po…

"There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. I didn't say that. However if you read the entire O/R modelling series you will see in PostgreSQL it is possible to fully define your model in an OO-like way in your database" Perhaps the area of disagreement in our interpretations is that I'm thinking "the database knows best" as in the DBA gets…

Perhaps the area of disagreement in our interpretations is that I'm thinking "the database knows best" as in the DBA gets the last word on what can be stored vs the DEV whereas I think you're defining the data definition in the DB as a DEV task, or maybe all DEVs should be both DBA and DEV, which I don't think will work very often but when it does work it's great.

Maybe. but I don't think I passed judgement on that issue. What I think I was saying was that if you have multiple applications writing to the same relation, you have to assume lax data controls on the part of every other writing app. I suspect, as I put in the article, that your view is that the API level should be app-level only, with web services instead of db queries.

Again, would be great if its possible. Probably one very important part of the workflow would be not to allow the DEVs to code in a MVC framework, essentially VC only, or just vestigial M like anything goes and rely solely on the DB for all data modeling. Otherwise each environment will have a different, probably incompatible, model.

Ok, let's look carefully at the role an ORDBMS plays in this, it is as an information model not a behavior model. The former is more or less a proper subset of the latter.

So things we can model are storage and retrieval stuff:

1) Save a GL transaction. Is it balanced? Throw error if not.

2) What is the balance of the checking account?

3) Store the info assuming we dispose of asset '12345-56665' by selling it for $100.

Things we should not do:

1) Presentation layer stuff

2) i18n stuff

3) Anything non-transactional (emails etc).

But the point is that the former category provides a save API for integration with other apps. The latter category is less important for integration. If the tools are there, however you can decide when and where they are appropriate. If they aren't there you don't have that choice.

One huge tradeoff though is that as soon as you go this direction you give up on portability and get really truly locked into one ORDBMS.

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#33
post #30

Earlier quoted context omitted.

Author here. Mysql - Model is in your code. PostgreSQL - Model is at least partially in your database. Also your code can be at least partly in your database which is what makes this possible. There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. I didn't say that. However if you read the entire O/R modelling series you will see in PostgreSQL it is po…

"There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. I didn't say that. However if you read the entire O/R modelling series you will see in PostgreSQL it is possible to fully define your model in an OO-like way in your database" Perhaps the area of disagreement in our interpretations is that I'm thinking "the database knows best" as in the DBA gets…

[deleted]

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#34
post #23

Earlier quoted context omitted.

postgres provides much more capabilities than just "dumb storage of the application's state"

No argument there. See my other posts in the Object/Relational modelling series for example.

I might refer to one of your comments to this entry: http://news.ycombinator.com/item?id=4495749

when your code goes into RDBMS engine, then it's no longer just a rdbms engine

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#36
post #18

Quick summary, assuming you know what MVC stands for: Mysql - Model is in your code. PostgreSQL - Model is at least partially in your database. There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. Its possible to come up with weird situations where you just want the DB to store stuff and not nanny you. Consider a database of actual, real world, grave…

Author here. Mysql - Model is in your code. PostgreSQL - Model is at least partially in your database. Also your code can be at least partly in your database which is what makes this possible. There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. I didn't say that. However if you read the entire O/R modelling series you will see in PostgreSQL it is po…

I've read through all your articles regarding "object relational modelling" and am still having a problem with the notion of, "in order to do a complex relational query, we need code in the database". Stonebraker isn't entirely impartial here as he's trying to sell his own product in this area (VoltDB) which is highly dependent on the "database-side logic" approach.

There's an important tradeoff being discussed here, which is, "can we get directly the data we want from the query", versus, "do we need to load all the data into our app first and filter it there". This is of course the critical thing that a lot more people need to learn, and the work I do with SQLAlchemy is all about this. But in the SQLA approach, we use Python constructs on the app side which expand into SQL functions when rendered in a query. The effect is very similar to that which I see in most of the examples in your posts.

While I think advanced data models and rich SQL-side functionality are essential, the usage of stored procedures is IMHO not the only way to get there. In practice I often use a mix of both, depending on how verbose the function needs to be.

Keeping SQL functions as app-side constructs has the advantage of source code management. It's easier to support multiple kinds of backends (I run against PG and SQL Server a lot) since you aren't tied to a stored procedure language. There's no need to emit new stored procedure definitions to the database in order to support new features of the application. You don't have the issue of updating a stored procedure on the database side such that multiple application versions, targeted to different versions of the database function, still continue to function. I think there are ways to approach these problems in favor of SPs, but they require some thought on how the source code is maintained, managed, and deployed. For now I've just stuck with keeping most SQL functions on the app side.

The big namespacing problems I see are, what if two different kinds of "classes" want to have the same method name ? The definition of a PG function here creates a name that's global to the whole schema - this suggests we may want names that are qualified with a "class name". And what if you do in fact need two versions of the same function present to support different application versions ? In that case maybe we want to qualify the names of the functions with version ids as well. This actually sets up a great opportunity to use an application side system of rendering class/version qualified SQL names in response to plain names on the app side.

I guess my point is that the "app logic in stored procedures" approach is interesting, it has some management/deployment issues that also might be interesting to solve, but app-rendered SQL when using an effective enough app-side toolkit can solve the problem just as well in most cases.

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#37
post #34

Earlier quoted context omitted.

No argument there. See my other posts in the Object/Relational modelling series for example.

I might refer to one of your comments to this entry: http://news.ycombinator.com/item?id=4495749 when your code goes into RDBMS engine, then it's no longer just a rdbms engine

Well, in this case that's one of the things that makes it an ORDBMS engine.

One of the interesting things about writing the series I have been working on PostgreSQL as an ORDBMS is that it has helped me solidify my understanding of how these features fit together. It has also forced me to think about separation of concerns a lot more.

What this has taught me so far is that PostgreSQL is an absolutely amazing data modelling platform. Sure that's a lot more than an RDBMS engine. The difference is somewhere between a math program capable of doing algebra and one capable of doing symbolic manipulation to solve derivatives and integrals. (Indeed this is forcing me to rethink the way I approach relational math to account for the sorts of things an ORDBMS can do.) So yeah it is a lot more.

But "just a database" is a hard statement to nail down. If BDB is "just a database" then MySQL is "not just a database." As Paul Brown put it in "Object Relational Database Development: A Plumber's Guide" this basically makes an ORDBMS an information backplane for software services. It becomes an interesting whether whether "database" is a superset of that or not.

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#38
post #13

I've never been able to completely dismiss MySQL since it obviously works for so many users, but I also haven't found it very useful in my work. I started with PostgreSQL in the '90s and every time I tried to use MySQL, I found myself asking either "why did it do that"? or "why would I want that"? The article describes two databases that are very different conceptually, and I think they're mirrored by users that conc…

One thing I would say matters a lot still even if you use an ORM is PostgreSQL's support for transactional DDL. No more worrying about migrations crashing in the middle. You should of course still test your migrations but one less thing to worry about is always nice.

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#39
post #15
post #11

every time I read a PostgreSql vs MySQL post the only thing I can seem to take away from it is that DBA's really seem to hate the fact that MySQL has made them obsolete and really want you to think you should switch to a platform where they are necessary.

The article wasn't written by a DBA. Reading isn't one of your strong points is it? Neither, if you think MySQL makes DBAs obsolete, is thinking.

While you're correct, the personal jabs are unnecessary.

This kind of thing cheapens the discussion here. Please take it somewhere else.

Re: PostgreSQL vs MySQL: an apples to oranges comparison

#40
post #19
post #18

Quick summary, assuming you know what MVC stands for: Mysql - Model is in your code. PostgreSQL - Model is at least partially in your database. There is a HUGE mistake in the article in the assumption that WRT the model design, that the database always knows best. Its possible to come up with weird situations where you just want the DB to store stuff and not nanny you. Consider a database of actual, real world, grave…

How is MySQL going to store "1890-02-30" as a date? What internal format does it use to allow storing a date like that?

I guess it uses a mixed-radix number with radixes 10-10-10-10-12-31 or 10000-12-31 (or, maybe, 10000-13-32 to allow for zero months and days) if the config flag ALLOW_INVALID_DATES (http://dev.mysql.com/doc/refman/5.5/en/server-sql-mode.html#...) is set.

I still fail to see why anybody would want that or even the default 'if you cannot figure it out, use 0000-00-00' mode, though. That flag makes a broken system more broken, and if someone wants more flexibility in storing dates, he could always use char(8) or so.

In the context of this article: if you use your database as a dumb store and put all logic in your application, why would you let MySQL decide for you that, e.g., 2000-12-34 becomes 0000-00-00 and not, for instance, 2001-01-03?

Post reply on HN