I enabled logging SQL queries for MySQL and saw that whenever I click on an email in kontact lots of SQL queries are being performed. After looking at the log I saw that they were also very similar/identical. There is only one unique SELECT, the others are being performed at least twice. Also atime ist updated three times (Also why is this stored anyway? I don't see any reason for it, but I may be wrong) The attached files contain the log for opening one email Reproducible: Always Steps to Reproduce: 1. Open an email in kontact 2. View MySQL log file Actual Results: Duplicate queries Expected Results: Every query should only be performed once
Created attachment 75787 [details] The MySQL log
Created attachment 75788 [details] The same log piped through sort and uniq -c As you can see most operations are being performed three times, I think it should be possible to reduce that
Also the queries in line 5 and 6 of the filtered log could be merged into one: ... WHERE ( ( PartTable.name IN ( 'PLD:RFC822', 'COLLECTIONID', 'ATR:ErrorAttribute' ) OR substr( PartTable.name, 1, 4 ) = ( 'PLD:' ) OR substr( PartTable.name, 1, 4 ) = ( 'ATR:' ) ) AND ( PimItemTable.id = 148263 ) ) ORDER BY PimItemTable.id DESC ... WHERE ( ( PartTable.name IN ( 'PLD:RFC822', 'COLLECTIONID', 'PLD:HEAD' ) OR substr( PartTable.name, 1, 4 ) = ( 'PLD:' ) OR substr( PartTable.name, 1, 4 ) = ( 'ATR:' ) ) AND ( PimItemTable.id = 148263 ) ) ORDER BY PimItemTable.id DESC The only difference is the third item in the IN (...) clause. It could be simplified to ... WHERE ( ( PartTable.name = 'COLLECTIONID' OR substr( PartTable.name, 1, 4 ) = ( 'PLD:' ) OR substr( PartTable.name, 1, 4 ) = ( 'ATR:' ) ) AND ( PimItemTable.id = 148263 ) ) ORDER BY PimItemTable.id DESC Or maybe even ... WHERE ( ( PartTable.name = 'COLLECTIONID' OR substr( PartTable.name, 1, 4 ) IN ( 'PLD:', 'ATR:' ) ) AND ( PimItemTable.id = 148263 ) ) ORDER BY PimItemTable.id DESC which is more readable and could also be faster.
This bug has only been reported for versions older than KDEPIM 4.14 (at most akonadi-1.3). Can anyone tell if this bug still present? If noone confirms this bug for a recent version of akonadi (part of KDE Applications 15.08 or later), it gets closed in about three months.
Just as announced in my last comment, I close this bug. If you encounter it again in a recent version (at least 5.0 aka 15.08), please open a new one unless it already exists. Thank you for all your input.