1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-18 20:04:00 +02:00

Speed up hot playlists by improving join performance

This commit is contained in:
Uwe L. Korn
2013-07-30 12:55:12 +02:00
parent a3aaf13981
commit 157ee8f433
5 changed files with 20 additions and 4 deletions

View File

@@ -0,0 +1,7 @@
-- Script to migate from db version 30 to 31.
-- Better indices to join playlist_item with other tables
CREATE INDEX playlist_item_trackname ON playlist_item(trackname);
CREATE INDEX playlist_item_artistname ON playlist_item(artistname);
CREATE INDEX artist_name ON artist(name);
CREATE INDEX track_name ON track(name);

View File

@@ -161,5 +161,6 @@
<file>data/js/cryptojs-core.js</file>
<file>data/js/cryptojs-sha256.js</file>
<file>data/sql/dbmigrate-29_to_30.sql</file>
<file>data/sql/dbmigrate-30_to_31.sql</file>
</qresource>
</RCC>

View File

@@ -46,7 +46,7 @@
*/
#include "Schema.sql.h"
#define CURRENT_SCHEMA_VERSION 30
#define CURRENT_SCHEMA_VERSION 31
Tomahawk::DatabaseImpl::DatabaseImpl( const QString& dbname )
{

View File

@@ -24,6 +24,7 @@ CREATE TABLE IF NOT EXISTS artist (
sortname TEXT NOT NULL
);
CREATE UNIQUE INDEX artist_sortname ON artist(sortname);
CREATE INDEX artist_name ON artist(name);
CREATE TABLE IF NOT EXISTS track (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -32,6 +33,7 @@ CREATE TABLE IF NOT EXISTS track (
sortname TEXT NOT NULL
);
CREATE UNIQUE INDEX track_artist_sortname ON track(artist,sortname);
CREATE INDEX track_name ON track(name);
CREATE TABLE IF NOT EXISTS album (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -90,6 +92,8 @@ CREATE TABLE IF NOT EXISTS playlist_item (
result_hint TEXT -- hint as to a result, to avoid using the resolver
);
CREATE INDEX playlist_item_playlist ON playlist_item(playlist);
CREATE INDEX playlist_item_trackname ON playlist_item(trackname);
CREATE INDEX playlist_item_artistname ON playlist_item(artistname);
CREATE TABLE IF NOT EXISTS playlist_revision (
guid TEXT PRIMARY KEY,
@@ -296,4 +300,4 @@ CREATE TABLE IF NOT EXISTS settings (
v TEXT NOT NULL DEFAULT ''
);
INSERT INTO settings(k,v) VALUES('schema_version', '30');
INSERT INTO settings(k,v) VALUES('schema_version', '31');

View File

@@ -1,5 +1,5 @@
/*
This file was automatically generated from ./Schema.sql on Mon Jul 29 21:04:33 CEST 2013.
This file was automatically generated from ./Schema.sql on Tue Jul 30 12:51:06 CEST 2013.
*/
static const char * tomahawk_schema_sql =
@@ -20,6 +20,7 @@ static const char * tomahawk_schema_sql =
" sortname TEXT NOT NULL"
");"
"CREATE UNIQUE INDEX artist_sortname ON artist(sortname);"
"CREATE INDEX artist_name ON artist(name);"
"CREATE TABLE IF NOT EXISTS track ("
" id INTEGER PRIMARY KEY AUTOINCREMENT,"
" artist INTEGER NOT NULL REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
@@ -27,6 +28,7 @@ static const char * tomahawk_schema_sql =
" sortname TEXT NOT NULL"
");"
"CREATE UNIQUE INDEX track_artist_sortname ON track(artist,sortname);"
"CREATE INDEX track_name ON track(name);"
"CREATE TABLE IF NOT EXISTS album ("
" id INTEGER PRIMARY KEY AUTOINCREMENT,"
" artist INTEGER NOT NULL REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
@@ -67,6 +69,8 @@ static const char * tomahawk_schema_sql =
" result_hint TEXT "
");"
"CREATE INDEX playlist_item_playlist ON playlist_item(playlist);"
"CREATE INDEX playlist_item_trackname ON playlist_item(trackname);"
"CREATE INDEX playlist_item_artistname ON playlist_item(artistname);"
"CREATE TABLE IF NOT EXISTS playlist_revision ("
" guid TEXT PRIMARY KEY,"
" playlist TEXT NOT NULL REFERENCES playlist(guid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
@@ -193,7 +197,7 @@ static const char * tomahawk_schema_sql =
" k TEXT NOT NULL PRIMARY KEY,"
" v TEXT NOT NULL DEFAULT ''"
");"
"INSERT INTO settings(k,v) VALUES('schema_version', '30');"
"INSERT INTO settings(k,v) VALUES('schema_version', '31');"
;
const char * get_tomahawk_sql()