I've been using sqlite3 in a python application, and when testing it, my queries sometimes cause the program to freeze up. A rough (from memory) example:
SELECT id,name FROM main_table WHERE name IN
(SELECT name FROM another_table WHERE another_table.attribute IN
('foo', 'bar', 'baz'))
Often, the first time I attempt something like this, the program simply freezes. Now, if I try the subquery first and then the whole nested mess, it works almost instantly.
I'm guessing that it's caching the results of the first, simpler query for later which makes things faster the next time around, but even so I'd like to know how to avoid this stalling in the first place.