Live data from Hacker News

Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

news.ycombinator.com

11–20 of 37 posts

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#11

One can argue about the statement that PostgreSQL is more feature rich. MySQL has more replication features, different storage engines, etc. also in MySQL GIS functionality is included and not an external plugin (like PostGIS) The source tree you looked at probably also has ndb cluster included; if you cloned from GitHub, you also get the MySQL Router and other side components. MySQL also bundles most external depend…

If you're a developer, a database is just a database. If you're a corporate DBA, they are each worlds apart. MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. The main issues with managing Postgres today are grant inheritance, and also the lack of COPY FROM/TO grants. I shouldn't have to update grants for non-admin or readonly users after adding new objects, and th…

> MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not.

Please elaborate on this “simply not”.. you are making a categorical statement.. does there exist a DISA-certified STIG for MySQL, for DoD and military applications?

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#12
post #11

Earlier quoted context omitted.

If you're a developer, a database is just a database. If you're a corporate DBA, they are each worlds apart. MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. The main issues with managing Postgres today are grant inheritance, and also the lack of COPY FROM/TO grants. I shouldn't have to update grants for non-admin or readonly users after adding new objects, and th…

> MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. Please elaborate on this “simply not”.. you are making a categorical statement.. does there exist a DISA-certified STIG for MySQL, for DoD and military applications?

I don't know what DISA or STIG are, but yes there are such projects. https://www.mysql.com/customers/industry/?id=65 has a few relevant references.

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#13

One can argue about the statement that PostgreSQL is more feature rich. MySQL has more replication features, different storage engines, etc. also in MySQL GIS functionality is included and not an external plugin (like PostGIS) The source tree you looked at probably also has ndb cluster included; if you cloned from GitHub, you also get the MySQL Router and other side components. MySQL also bundles most external depend…

If you're a developer, a database is just a database. If you're a corporate DBA, they are each worlds apart. MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. The main issues with managing Postgres today are grant inheritance, and also the lack of COPY FROM/TO grants. I shouldn't have to update grants for non-admin or readonly users after adding new objects, and th…

> MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not.

I find this statement amazingly weird. In my experience, MySQL's access grants are extremely impoverished compared to Postgres (even in 8). It doesn't have row level security either.

> The main issues with managing Postgres today are grant inheritance

roles + `INHERIT` (which has been available since at least 8.1, 15 years ago)

> I shouldn't have to update grants for non-admin or readonly users after adding new objects

You don't. There are default grants that apply on object creation within a schema: `ALTER DEFAULT PRIVILEGES`.

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#14
post #11

Earlier quoted context omitted.

If you're a developer, a database is just a database. If you're a corporate DBA, they are each worlds apart. MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. The main issues with managing Postgres today are grant inheritance, and also the lack of COPY FROM/TO grants. I shouldn't have to update grants for non-admin or readonly users after adding new objects, and th…

> MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. Please elaborate on this “simply not”.. you are making a categorical statement.. does there exist a DISA-certified STIG for MySQL, for DoD and military applications?

There is no certified MySQL STIG yet. There is one for Postgres though.

STIGs are hardening guidelines used the US Department of Defense.

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#15

One can argue about the statement that PostgreSQL is more feature rich. MySQL has more replication features, different storage engines, etc. also in MySQL GIS functionality is included and not an external plugin (like PostGIS) The source tree you looked at probably also has ndb cluster included; if you cloned from GitHub, you also get the MySQL Router and other side components. MySQL also bundles most external depend…

If you're a developer, a database is just a database. If you're a corporate DBA, they are each worlds apart. MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. The main issues with managing Postgres today are grant inheritance, and also the lack of COPY FROM/TO grants. I shouldn't have to update grants for non-admin or readonly users after adding new objects, and th…

sigh

Must you really draw conclusions about the suitability of PostgreSQL or MySQL for all users based on your limited perspective/niche needs?

> If you're a developer, a database is just a database.

[screams internally]

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#17
post #11

Earlier quoted context omitted.

> MySQL is a perfect match for most SaaS applications that deal with compliance. Postgres is simply not. Please elaborate on this “simply not”.. you are making a categorical statement.. does there exist a DISA-certified STIG for MySQL, for DoD and military applications?

I don't know what DISA or STIG are, but yes there are such projects. https://www.mysql.com/customers/industry/?id=65 has a few relevant references.

There isn't a STIG for MySQL... yet. Supposedly there is one being worked on, however.

There's been a Postgres STIG for, I dunno, "a while" now.

--

DISA: https://en.wikipedia.org/wiki/Defense_Information_Systems_Ag...

STIG: https://en.wikipedia.org/wiki/Security_Technical_Implementat...

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#18

One can argue about the statement that PostgreSQL is more feature rich. MySQL has more replication features, different storage engines, etc. also in MySQL GIS functionality is included and not an external plugin (like PostGIS) The source tree you looked at probably also has ndb cluster included; if you cloned from GitHub, you also get the MySQL Router and other side components. MySQL also bundles most external depend…

> MySQL also bundles most external dependencies (excluding for example boost)

This is a great callout. Most people running PG for serious production probably need pgbouncer which looks like it adds 35-50K lines. There's probably a few more 50K-ish plugins that are must haves for serious usage.

I don't know how many lines NDB is, but the lack of a standard failover mechanism and cluster manager in Postgres is a pain. The number of effective lines that the bespoke systems people build for that purpose is probably quite large.

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#19
So I cloned the mysql-server and postgres repos and ran sloccount. It's not the deepest dive or anything but was interesting.

I saw MySQL had...600k lines of JavaScript?

It turned out that the storage/ndb directory had a Web-based management interface for NDB, which vendors in the Dojo JavaScript framework. It also had ~50k lines of Java for the "ClusterJ" framework, which interfaces with NDB skipping the SQL layer. Overall, sloccount reports about 1.4M lines of code in storage/ndb/.

NDB is a specialized cluster database where all secondary indexes have to fit in the cluster's RAM(!). Work on it started at Ericsson, then it was spun out into a startup which MySQL AB eventually bought. I imagine MySQL management at the time hoped the future of DB clusters might end up looking more like NDB and less like...gestures at today's database landscape.

There are also ~500K lines of Unicode tables in the strings/ directory. I recall Postgres calls out to libc for locale/collation related stuff so probably doesn't need those tables in-tree.

Even accounting for those chunks you still end up with ~1M vs ~2M SLOC as measured by sloccount. (I don't want to pretend the numbers are super precise.) There are probably other differences in what's in scope for the repo or other surprises. [Edit: see johannes1234321's comment which lists some of them.]

Besides those, though, might be truth to others' comments about MySQL spending lots of code supporting drastically different old and new "worlds" in a single binary (non-transactional and transactional storage, originally very-nonstandard vs. currently more-standard SQL, statement-based and row-based replication...). And at a totally non-technical level, as a product MySQL seems to have had more money thrown at it and that tends to mean more code.

This was fun but was an incredibly quick and dirty dive into it, and I'd love to hear more from folks who can look more or just know more.

Re: Ask HN: How PostgreSQL source code is 3x shorter than MySQL's one?

#20

So I cloned the mysql-server and postgres repos and ran sloccount. It's not the deepest dive or anything but was interesting. I saw MySQL had...600k lines of JavaScript? It turned out that the storage/ndb directory had a Web-based management interface for NDB, which vendors in the Dojo JavaScript framework. It also had ~50k lines of Java for the "ClusterJ" framework, which interfaces with NDB skipping the SQL layer.…

I was watching Sherlock Holmes tonight and for some reason I read that in Benedict Cumberbatches voice, most entertaining, thank you!
Post reply on HN