Live data from Hacker News

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

news.ycombinator.com

31–37 of 37 posts

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

#31
post #5

MySQL has a storage abstraction and includes multiple storages.

I think you will always find something that the other product doesn't have (or doesn't have in the same way)

Postgres e.g. has the infrastructure for extendable data types and index types and the infrastructure for extensions - none of that can be found in MySQL and that infrastructure needs source code as well.

I don't think the nearly 3-fold difference can't be attributed to "features", but to other things. Maybe the projects are structured differently or include different additional tools in their code (e.g. the input files to generate the SQL parser, rather than the generated parser's C code).

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

#32

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.…

NDB is a specialized cluster database where all secondary indexes have to fit in the cluster's RAM(!). That’s not that wild of a design principle: It’s been longstanding best practice to scale OLTP databases (and limit indexing) as to keep secondary indexes buffered in memory.

To explain that statement: Historically ndb worked in a way that all data had to be in memory and it wouldn't touch the disk at all. For a while now data can be on disk, but all indexes afaik still have to be fully loaded into memory in startup.

The use cases are systems where you need "five nines" of uptime and fat responses. Coming out of Ericsson the classic area where it is used is in Telco (for instance "home location registers", the database recoding in which cell a mobile phone currently is, often use ndb) but there are different usages in Web (i.e. Session Store), "real time" information exchange (betting, gaming, ...) and so on.

It is not as easy to administer as a "normal" MySQL, but when deployed carefully it is powerful, fast and scalable (both locally as well as geo l-level)

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

#33

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…

>One can argue about the statement that PostgreSQL is more feature rich.

I dont even think it should be an argument. Postgre by default, on itself without extension is anything but feature rich, especially when comparing to MySQL.

I like Postgre, and I know lots of people on HN do too, and I also know these same people absolutely hate oracle. But come on.

Sometimes these Hype and cult is just a little too much.

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

#34
post #33

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…

>One can argue about the statement that PostgreSQL is more feature rich. I dont even think it should be an argument. Postgre by default, on itself without extension is anything but feature rich, especially when comparing to MySQL. I like Postgre, and I know lots of people on HN do too, and I also know these same people absolutely hate oracle. But come on. Sometimes these Hype and cult is just a little too much.

Why the weird misspelling?

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

#35
post #30

That the source is much larger I don't mind _so much_. But this recent thing mysql is doing worries me more. ls -lah /usr/sbin/mysqld -rwxr-xr-x 1 root root 1.1G Mar 26 2020 /usr/sbin/mysqld 1.1G binary.

How did that happen? This system's `mysqld` (from mariadb-10.4.14) is 22 MB. Even the biggest binary is only 100 MB. stat -c '%s %n' /usr/{bin,sbin}/*|sort -nr|head -20 100034576 /usr/bin/blender 63352576 /usr/bin/godot 61299448 /usr/bin/scummvm 61004336 /usr/bin/godot-headless 55123448 /usr/bin/podman 42794056 /usr/bin/podman-remote 30582984 /usr/bin/makemkv 29998400 /usr/bin/godot-runner 29340272 /usr/bin/cabal 280…

regular rpm install mysql 8 community edition

mysql-community-server-8.0.20-1.el7.x86_64

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

#36

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.…

Can you give some recommendations for must have plugins? I have a few Postgres databases running in production and none is more than the default docker image from Docker Hub
Post reply on HN