Here are some hard numbers - used half my library to make it more reasonable comparison.
SETUP
- OSMC October 2017 on Vero 4K - Custom Patch to not cache any windows and therefore execute SQL statements everytime even when they take more than 1 second to prevent inconsistencies in displaying episode counts or watched status - see inital post.
- MariaDB 10.0 on a Synology DS214+
- WLAN connection - some latency here for sure in general.
- Library Size for Testing: 253 TV Shows, 13594 Episodes (481 Unwatched) - used only half my library for testing for more comparable numbers. The larger the more extreme the difference will be.
- Index for played count added to files table because of my library nodes that often execute queries where watchcount is involved.
Only ran one test, but you already get the picture. Normal network activity at home.
REFRESHING RECENTLY ADDED EPISODE WIDGET
OLD: RunQuery took 202 ms for 481 items:
NEW: RunQuery took 129 ms for 481 items
Original episode_view because it fast enough ) as it is just a simple join. Note I have an additional index set on the files table for playcount.
OPENING TV SHOWS
OLD: RunQuery took 1341 ms for 253 items
NEW: RunQuery took 520 ms for 253 items
Original view is significant slower, though still acceptable.
OPENING TV SHOWS WITH UNWATCHED EPISODES
OLD: RunQuery took 945 ms for 28 items
NEW: RunQuery took 85 ms for 28 items
Ouchā¦ That difference in performance is not acceptable. As soon as some WHERE clauses come in on tvshow_view the problem of the view start to show as values are counted each time.
OPENING IN PROGRESS EPISODES
OLD: RunQuery took 32 ms for 7 items
NEW: RunQuery took 11 ms for 7 items
Original episode_view is fast enough as it is just a simple join.
OPENING RECENTLY ADDED EPISODES
OLD: RunQuery took 200 ms for 481 items
NEW: RunQuery took 149 ms for 481 items
Original episode_view is fast enough as it is just a simple join
OPENING LARGE SEASON (X-FILES 10 SEASONS WITH 210 EPISODES)
OLD: RunQuery took 3716 ms for 11 items
NEW: RunQuery took 6 ms for 11 items
Muwahahaha. The season_view is just bad. Unacceptable bad.
OPENING EPSIODES (X-FILES 1ST SEASON)
OLD: RunQuery took 29 ms for 24 items
NEW: RunQuery took 15 ms for 24 items
Original epsiode_view is fast enough as it is just a simple join
So what is the result:
- season_view has to go. It is absolutely unacceptable
- tv_show_view has to go as well depending on the query it can slow down things a lot, also season_view uses it for some data sigh
- tvshowcounts seems ok, has not much impact, but will shave of a bit on the season view as well. Debatable
- episode_view seems fine as it is a simple join with not much performance impact.
Anyway, big improvement everywhere overall especially with changing seasons_view and tv_show to a table. And that is important as you easily drill down from Show ā Season ā Episode and waiting for the seasons for several seconds is just painful.
The rest just icing on the cake to shave of a few more ms. I guess I leave then as tables now.
Doing the movie_view will not result in much improvement, as it is once more a select * and it is more or less a simple join similar to episode_view. Not much I can do here. But itās not like movies increase every week by a few. So putting more into sets will probably help to cut the list down.
Music? I bet there will be an improvement, But not really interested in it right now.
EDIT:
I repeated the rests a bit like running the queries Kodi did 100 times in a row. Well first, Kodi itself seams to create some overhead here as well when receiving and does some processing with it before it opens the window. Too lazy to check the code what is done there. What is logged basically matches until I see something on screen.
Also most of the longer queries seems to be network related delays as well, meaning mysql client talking to the server. Well with a bigger data set no wonder, even though the data itself is still quite small.
The queries are executed now lightning fast on the server itself, so throwing more RAM or tweaking some settings does nothing to it. We already talking a few ms, just takes time until it reaches the client and is processed by Kodi.
For example the āselect * from tvshow_viewā query takes 0.4ms on the server, well itās a āselect *ā so nothing much to do and no view involved here. Then it takes about 250ms to get it to Kodi. And there it takes about 250ms to be processed (then time is logged) and next Window is opened.
So all in all full success. I canāt get Kodi tables here any faster on the SQL side. Optimization must be done on the Kodi side in processing it (whatever takes additional 250ms) and working with smaller data sets (now we enter architectural problems of Kodi itself).