Add index on tweets user_id column to accelerate building user feed

This commit is contained in:
Alessio 2022-12-26 13:08:25 -05:00
parent 83a6edb257
commit 1558c321b6
2 changed files with 4 additions and 2 deletions

View File

@ -62,6 +62,7 @@ create table tweets (rowid integer primary key,
foreign key(space_id) references spaces(id) foreign key(space_id) references spaces(id)
); );
create index if not exists index_tweets_in_reply_to_id on tweets (in_reply_to_id); create index if not exists index_tweets_in_reply_to_id on tweets (in_reply_to_id);
create index if not exists index_tweets_user_id on tweets (user_id);
create table retweets(rowid integer primary key, create table retweets(rowid integer primary key,

View File

@ -8,7 +8,7 @@ import (
"offline_twitter/terminal_utils" "offline_twitter/terminal_utils"
) )
const ENGINE_DATABASE_VERSION = 15 const ENGINE_DATABASE_VERSION = 16
type VersionMismatchError struct { type VersionMismatchError struct {
EngineVersion int EngineVersion int
@ -87,7 +87,7 @@ var MIGRATIONS = []string{
alter table spaces add column started_at integer; alter table spaces add column started_at integer;
alter table spaces add column ended_at integer; alter table spaces add column ended_at integer;
alter table spaces add column updated_at integer; alter table spaces add column updated_at integer;
alter table spaces add column is_available_for_replay boolean not null; alter table spaces add column is_available_for_replay boolean not null default 0;
alter table spaces add column replay_watch_count integer; alter table spaces add column replay_watch_count integer;
alter table spaces add column live_listeners_count integer; alter table spaces add column live_listeners_count integer;
alter table spaces add column is_details_fetched boolean not null default 0; alter table spaces add column is_details_fetched boolean not null default 0;
@ -96,6 +96,7 @@ var MIGRATIONS = []string{
space_id not null, space_id not null,
foreign key(space_id) references spaces(id) foreign key(space_id) references spaces(id)
);`, );`,
`create index if not exists index_tweets_user_id on tweets (user_id);`,
} }
/** /**