Search code examples
mysqlpostgresqlrdbms

Do Most/Typical Databases Use Stdio?


I couldn't find any documentation or anything answering my question anywhere. Do rdbms like postgres or mysql use the c libraries to write data just as ordinary files?

Or do they just try to get a hold of the raw disk memory space address locations and write to it? Surely not, because the linux kernel doesn't allow that. Surely kernels context switching and memory ownership models slow down DB transactions.

I'm curious what this looks like under the hood.


Solution

  • Both MySQL and PostgreSQL are open-source. You can check for yourself.

    https://github.com/mysql/mysql-server/blob/5.7/include/my_global.h#L53

    #include <stdio.h>
    

    https://github.com/postgres/postgres/blob/master/src/include/c.h#L59

    #include <stdio.h>
    

    MySQL has a feature to do raw I/O directly to disk partitions. But with modern filesystems, it's doubtful that this has much benefit. I've never worked on an instance of MySQL that was configured this way.

    As far as I know, PostgreSQL never supported I/O to raw disk partitions.