I've saved a table of lightcurves to mydb and I'm trying to INNER JOIN some small, temporary tables to get subsets of that table. In doing so, I found my queries were running seemingly forever. I've been able to reproduce the issue with a minimal working example, but I don't understand it. mydb://temp is one of the small temporary tables, and mydb://stable_lcs is the big table holding all the lightcurves I'm interested in.
This query: SELECT objectid FROM mydb://temp LIMIT 2 returns results 182752_32789, 185281_28807 in less than a second.
This query: SELECT * FROM mydb://stable_lcs WHERE objectid IN ('182752_32789', '185281_28807')" returns their lightcurves, as expected, also in less than a second.
If I nest these: SELECT * FROM mydb://stable_lcs WHERE objectid IN (SELECT objectid FROM mydb://temp LIMIT 2) this query runs seemingly forever. Moreover, if I stop the execution and rerun the first query, now that query takes forever too. Eventually, like 5-10 minutes or so, I can query mydb://temp again. Why?