Index on tts results creation date, query on popular models by date

This commit is contained in:
Brandon Thomas committed 2022-07-09 13:16:32 -04:00
1 parent b71278aef1
commit d4afc42d5c
3 files changed
+22

No files matched your search

@@ -0,0 +1,5 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
DROP INDEX `index_created_at` ON `tts_results`;
@@ -0,0 +1,5 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
CREATE INDEX `index_created_at` ON `tts_results` (`created_at`);
@@ -0,0 +1,12 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
select m.token, m.title, r.use_count from (
select model_token, count(*) as use_count from tts_results
where created_at < now() - interval 30 day
group by model_token
order by use_count desc limit 100
) as r
join tts_models as m
on m.token = r.model_token;