diff --git a/autotests/libs/itemappendtest.cpp b/autotests/libs/itemappendtest.cpp
--- a/autotests/libs/itemappendtest.cpp
+++ b/autotests/libs/itemappendtest.cpp
@@ -55,6 +55,7 @@
QTest::newRow("whitespace") << QStringLiteral("remote id");
QTest::newRow("quotes") << QStringLiteral("\"remote\" id");
QTest::newRow("brackets") << QStringLiteral("[remote id]");
+ QTest::newRow("RID length limit") << QStringLiteral("a").repeated(1024);
}
void ItemAppendTest::testItemAppend()
@@ -399,3 +400,4 @@
QVERIFY(file.exists());
QVERIFY(file.remove());
}
+
diff --git a/src/server/storage/akonadidb.xml b/src/server/storage/akonadidb.xml
--- a/src/server/storage/akonadidb.xml
+++ b/src/server/storage/akonadidb.xml
@@ -67,7 +67,7 @@
Contains the schema version of the database.
-
+
@@ -126,7 +126,7 @@
-
+
diff --git a/src/server/storage/dbconfigpostgresql.cpp b/src/server/storage/dbconfigpostgresql.cpp
--- a/src/server/storage/dbconfigpostgresql.cpp
+++ b/src/server/storage/dbconfigpostgresql.cpp
@@ -419,6 +419,18 @@
// postgres data directory not initialized yet, so call initdb on it
if (!QFile::exists(QStringLiteral("%1/PG_VERSION").arg(mPgData))) {
+#ifdef Q_OS_LINUX
+ // It is recommended to disable CoW feature when running on Btrfs to improve
+ // database performance. This only has effect when done on an empty directory,
+ // so we call this before calling initdb.
+ if (Utils::getDirectoryFileSystem(mPgData) == QLatin1String("btrfs")) {
+ Utils::disableCoW(mPgData);
+ }
+#endif
+ // call 'initdb --pgdata=/home/user/.local/share/akoandi/db_data'
+ execute(mInitDbPath, { QStringLiteral("--pgdata=%1").arg(mPgData),
+ QStringLiteral("--locale=en_US.UTF-8") // TODO: check locale
+ });
} else {
const auto versions = checkPgVersion();
if (versions.has_value() && (versions->clusterVersion < versions->pgServerVersion)) {
diff --git a/src/server/storage/dbinitializer_p.cpp b/src/server/storage/dbinitializer_p.cpp
--- a/src/server/storage/dbinitializer_p.cpp
+++ b/src/server/storage/dbinitializer_p.cpp
@@ -19,7 +19,9 @@
***************************************************************************/
#include "storage/dbinitializer_p.h"
+#include
+using namespace Akonadi;
using namespace Akonadi::Server;
//BEGIN MySQL
@@ -64,7 +66,10 @@
}
columns << references;
- const QString tableProperties = QStringLiteral(" COLLATE=utf8_general_ci DEFAULT CHARSET=utf8");
+ QString tableProperties = QStringLiteral(" COLLATE=utf8_general_ci DEFAULT CHARSET=utf8");
+ if (tableDescription.columns | any([](const auto &col) { return col.type == QLatin1String("QString") && col.size > 255; })) {
+ tableProperties += QStringLiteral(" ROW_FORMAT=DYNAMIC");
+ }
return QStringLiteral("CREATE TABLE %1 (%2) %3").arg(tableDescription.name, columns.join(QStringLiteral(", ")), tableProperties);
}
diff --git a/src/server/storage/dbupdate.xml b/src/server/storage/dbupdate.xml
--- a/src/server/storage/dbupdate.xml
+++ b/src/server/storage/dbupdate.xml
@@ -346,4 +346,10 @@
+
+
+
+ ALTER TABLE PimItemTable ROW_FORMAT=DYNAMIC
+ ALTER TABLE PimItemTable MODIFY COLUMN remoteId VARBINARY(1024)
+
diff --git a/src/server/storage/mysql-global-mobile.conf b/src/server/storage/mysql-global-mobile.conf
--- a/src/server/storage/mysql-global-mobile.conf
+++ b/src/server/storage/mysql-global-mobile.conf
@@ -58,6 +58,9 @@
# Size of each log file in a log group (default:5M) larger means less I/O but more time for recovery.
innodb_log_file_size=2M
+# Enable varchar index keys up to 3072 bytes (1024 characters), compared to 768 bytes (255 characters) with normal settings
+innodb_large_prefix=1
+
# # error log file name, relative to datadir (default:hostname.err)
log_error=mysql.err