を選択して、私は次のテーブルを持っている:明確な大規模なデータベースのために長い時間を要する
CREATE TABLE notes (noteId INTEGER PRIMARY KEY ASC, note, note_length, count, unique(note) on conflict abort)
また3万行が含まれています。
私は、次のコマンドを実行します。ただし
def getDistintNoteCountList(note_length):
with sqlite3.connect(r'./note_database') as connection:
cursor = connection.cursor()
cursor.execute('select distinct count from notes where note_length = ?', [note_length])
return [i[0] for i in cursor]
を、それが返されたリストには、周りの20の大きさを持って実行するには、この機能のために30秒かかり、私は300万を持っていることを考えると、この合理的です私は間違ったことをしていますか?
おかげで、
バリー
EDIT
を追加しました:
cursor.execute("create index countIndex on notes (count)")
cursor.commit()
、データベースにデータを再ロード。それはまだまるで遅いようです。
カウントにインデックスを追加しようとしましたか? – dasblinkenlight