Improving the Speed of Digikam using MySQL

Digikam is great for organizing pictures, yet above 20,000 pictures it can begin to slow down. The migration process is very easy since Digikam can migrate the data for you. And I’ll show you some options that help speed up MySQL even more.

Migrate to MySQL

First, make a backup of your current database.

If you don’t have digikam using MySQL yet, first you’ll need to setup MySQL on your desktop, or you can use the built in MySQL server that digikam can run. I’m not going to go into installing a database here. A quick search will give you move than enough articles to do so.

And to use digikam’s internal Mysql server, go to Settings > Configure digikam > Database and it’s in the dropdown.

Once you get that going use the Database Migration tool under Settings to move it over. You’ll choose your current database, and then on the right you’ll choose the one it’s going to. You can find more on that from the user docs.

Then once you’ve done so, set your MySQL settings under Settings > Configure digikam > Database.

Use a unix socket

Unix sockets are a lot faster than tcp connections. And they have lower latency (no three way handshake). By default your install will probably use tcp connections. But let’s use sockets and sock it to that latency.

Ya, bad pun.

Ok, go to the Digikam Database configuration: Settings > Configure digikam > Database

Set your Host name to localhost. If you set it to then it will try to use a regular tcp connection.

In the ‘Connect options’ put this in there:


Make sure your socket is correct (yours may be different. Use your distro’s setup). Check your /etc/my.cnf and any related ones in /etc/my.cnf.d/. You’ll be checking for something like:


Make sure UNIX_SOCKET matches that.

Here’s the reference page I used for QT5’s options for databases, in case you’re interested.

Increase Your MySQL Performance

In your mysql.cnf (or in /etc/my.cnf.d/), under the [mariadb] or [mysql] headings, we will want to increase max_allowed_packet settings to improve performance. Here’s some you can set:

# speed up large collections in digikam

And this is a good thing to always put in if your database is only supposed to be accessed by your computer (it turns off all network access):

# recommended for security
bind-address =

Then restart MySQL. That’s it!