Try to speed up getting actor id

- Explicitly select only 1 entry
This commit is contained in:
tomkat83 2016-12-04 12:29:52 +01:00
parent f02bb4a873
commit 30f9518b82

View file

@ -283,7 +283,8 @@ class Kodidb_Functions():
"SELECT actor_id", "SELECT actor_id",
"FROM actor", "FROM actor",
"WHERE name = ?", "WHERE name = ?",
"COLLATE NOCASE" "COLLATE NOCASE",
"LIMIT 1"
)) ))
self.cursor.execute(query, (name,)) self.cursor.execute(query, (name,))
try: try:
@ -292,7 +293,7 @@ class Kodidb_Functions():
# Cast entry does not exists # Cast entry does not exists
self.cursor.execute("select coalesce(max(actor_id),0) from actor") self.cursor.execute("select coalesce(max(actor_id),0) from actor")
actorid = self.cursor.fetchone()[0] + 1 actorid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO actor(actor_id, name) values(?, ?)" query = "INSERT INTO actor(actor_id, name) VALUES (?, ?)"
self.cursor.execute(query, (actorid, name)) self.cursor.execute(query, (actorid, name))
return actorid return actorid