Skip to content
Advertisement

How to improve SQL query performance for HAVING (SQLite)

These 2 queriess are taking several minutes on tables of several millions rows (2 tables: torrents and dates). None of the columns are indexed I believe. I don’t know SQL well. Is there any way to make them faster?

Here are the queries:

Advertisement

Answer

You don’t need the GROUP BY or HAVING clauses

The first one probably doesn’t even need the WHERE dates.date IS NULL since I assume that there’s no record in the dates table without a date. UPDATE: But then you would need to change the LEFT JOIN to INNER JOIN.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement