I have a table with many rows and I'd like to speed up my query. This is the original query:
cursor.execute("""select id, data
from events
where processed IS NULL and instr(data, 'Captain') = 0;""")
I thought I could speed things up by first selecting only the unprocessed rows and then searching the text of the data
variable. But this is also slow.
cursor.execute("""select x.id, x.data
from
(select a.id, a.data from events as a where a.processed IS NULL) as x
where instr(x.data, 'Captain') = 0;""")
Any thoughts on how I could filter the processed column for NULL before searching through data
?