Synlogy Diskstation Count Universal Search Database entries

In my previous post I explained how to delete the Universal Search database. But even with a fresh database the index process didn't stop even after running for 2 weeks. Other users reported similar problems [1], [2].

So I had a look at the database tables and wrote a script which counts the entries in those tables. I'll add the script at the end of the article.

Testing the script in I noted that after just half an hour no new entries where added to the database. The index process stayed like this:

Screenshot at Sep 25 200620.png

The 4023 results for music seems about right so the index process might be stuck either at one of the last music files or at the beginning of the next task.

Either way, the index service continues to use about 50% CPU while not doing anything useful:

image.png

I suspect a bug in the index process and it's probably best to set the index service to delay forever and try again after the next update of Universal Search.

image.png

There is also a hotfix for those not affright of burning themselves.

Scipt

WARNING: From this point onwards you need advanced Linux skills. If you don't know how to use ssh, sudo or su you should stop reading. I will take no responsibility if you brick your Diskstation.

The script will count the entries in the «mediaserver» database. For this two user changes are needed:

  1. First the script elevates itself to root privileges to stop and later start the search service.
  2. Then the script demotes itself to postgres privileges to delete the database.

The script need to stored at a place where every user can access it. Otherwise the user changes won't work. Alternatively you can make the user changes manually.

#!/bin/bash

Script="$(readlink -f ${0})"

echo execute «${Script}» as «${USER}»

if test "${USER}" = "postgres"; then
    /bin/psql <<-EOF
        \c mediaserver
        SELECT 'directory',             count (*) FROM "directory"          UNION
        SELECT 'personal_directory',    count (*) FROM "personal_directory" UNION
        SELECT 'music',                 count (*) FROM "music"              UNION
        SELECT 'photo',                 count (*) FROM "photo"              UNION
        SELECT 'track',                 count (*) FROM "track"              UNION
        SELECT 'album_track',           count (*) FROM "album_track"        UNION
        SELECT 'artist_track',          count (*) FROM "artist_track"       UNION
        SELECT 'composer_track',        count (*) FROM "composer_track"     UNION
        SELECT 'genre_track',           count (*) FROM "genre_track"        UNION
        SELECT 'playcount_track',       count (*) FROM "playcount_track"    UNION
        SELECT 'rating_track',          count (*) FROM "rating_track"       UNION
        SELECT 'replaygain_track',      count (*) FROM "replaygain_track"   UNION
        SELECT 'virtual_info_track',    count (*) FROM "virtual_info_track" UNION
        SELECT 'playlist',              count (*) FROM "playlist"           UNION
        SELECT 'playlist_sharing',      count (*) FROM "playlist_sharing"   UNION
        SELECT 'personal_playlist',     count (*) FROM "personal_playlist"  UNION
        SELECT 'pin',                   count (*) FROM "pin"                UNION
        SELECT 'video',                 count (*) FROM "video"              UNION
        SELECT 'video_convert',         count (*) FROM "video_convert"      UNION
        SELECT 'virtual_music',         count (*) FROM "virtual_music"      UNION
        SELECT 'voice_search',          count (*) FROM "voice_search"       ORDER BY "count";
        \q
    EOF
elif test "${USER}" = "root"; then
    su --command "${Script}" - postgres
else
    sudo ${Script}
fi


posts5060.pngcomments5870.pngvotes6680.pnglevel9090.pngpayout6680.pngcommented5870.pngvoted5060.png

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now