-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added: index to the basePath columns for faster retrieval
- Loading branch information
Jonathan Marshall
committed
Mar 8, 2011
1 parent
606fcbc
commit cdb8fc1
Showing
2 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails with:
Since MySQL can't index TEXT/BLOBs without index length provided.
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup - I'm waiting on someone to test the obvious fix:
CREATE index ixMovieBasePath on movie(c22(255))
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works fine on mysql. not on sqlite though :)
dush@crichton:~/github/xbmc$ echo "CREATE index ixMovieBasePath on movie(c22 (255));" | sqlite3 ~/.xbmc/userdata/Database/MyVideos46.db
Error: near line 1: near "(": syntax error
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could by the version of sqlite that I got installed
22:38:43 T:3024549696 M:2947600384 NOTICE: Attempting to update the database MyVideos46.db from version 44 to 46
22:38:43 T:3024549696 M:2947600384 ERROR: SQL: SQL error or missing database
Query: CREATE INDEX ixMovieBasePath ON movie ( c22(255) )
22:38:43 T:3024549696 M:2947600384 ERROR: Error attempting to update the database version!
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the exec() command will strip out the constrained index for sqlite databases within XBMC, so testing it at the command line will fail.
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the queries to "CREATE UNIQUE INDEX" and it the filter will pick it up. "CREATE UNIQUE INDEX" is supported by both sqlite and mysql.
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not unique though. if you make it unique, it'll fail when you add something with a large (>255 chars) length path.
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah very true, who has paths that long anyways ;)
the solution then is to add "CREATE INDEX" as a valid trigger for the filter in xbmc/dbwrappers/sqlitedataset.cpp
change line 484:
if ( qry.find("CREATE UNIQUE INDEX") != string::npos )
to something like (or similar to)
if ( (qry.find("CREATE UNIQUE INDEX") != string::npos) || (qry.find("CREATE INDEX") != string::npos) )
cdb8fc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed the fix in 999e8d0 and 8438004