Attempt number 2 on a larger dataset; the people table.

Note: This has a previously applied optimization of using a local cache.

Before:
```
458570   66.934    0.000   66.934    0.000 {method 'execute' of 'sqlite3.Cursor' objects}
246771   58.075    0.000   58.075    0.000 {method 'fetchone' of 'sqlite3.Cursor' objects}
```

After:
```
368883   66.220    0.000   66.220    0.000 {method 'execute' of 'sqlite3.Cursor' objects}
157084   58.160    0.000   58.160    0.000 {method 'fetchone' of 'sqlite3.Cursor' objects}
```

Once again, the number of calls to execute and fetchone are reduced but
the total time spent executing each is relatively stable.
This commit is contained in:
Chuddah 2020-02-23 18:27:12 +00:00
parent 0a69894320
commit 6fe450da4d
2 changed files with 4 additions and 13 deletions

View file

@ -40,11 +40,6 @@ class Kodi(object):
return self.cursor.fetchone()[0] + 1 return self.cursor.fetchone()[0] + 1
def create_entry_person(self):
self.cursor.execute(QU.create_person)
return self.cursor.fetchone()[0] + 1
def create_entry_genre(self): def create_entry_genre(self):
self.cursor.execute(QU.create_genre) self.cursor.execute(QU.create_genre)
@ -164,8 +159,8 @@ class Kodi(object):
def add_person(self, *args): def add_person(self, *args):
person_id = self.create_entry_person() self.cursor.execute(QU.add_person, args)
self.cursor.execute(QU.add_person, (person_id,) + args) return self.cursor.lastrowid
return person_id return person_id

View file

@ -12,10 +12,6 @@ create_file = """
SELECT coalesce(max(idFile), 0) SELECT coalesce(max(idFile), 0)
FROM files FROM files
""" """
create_person = """
SELECT coalesce(max(actor_id), 0)
FROM actor
"""
create_genre = """ create_genre = """
SELECT coalesce(max(genre_id), 0) SELECT coalesce(max(genre_id), 0)
FROM genre FROM genre
@ -225,8 +221,8 @@ VALUES (?, ?, ?)
""" """
add_file_obj = ["{PathId}", "{Filename}"] add_file_obj = ["{PathId}", "{Filename}"]
add_person = """ add_person = """
INSERT INTO actor(actor_id, name) INSERT INTO actor(name)
VALUES (?, ?) VALUES (?)
""" """
add_people_movie_obj = ["{People}", "{MovieId}", "movie"] add_people_movie_obj = ["{People}", "{MovieId}", "movie"]
add_people_mvideo_obj = ["{People}", "{MvideoId}", "musicvideo"] add_people_mvideo_obj = ["{People}", "{MvideoId}", "musicvideo"]