20 lines
623 B
SQL
20 lines
623 B
SQL
-- Indexes are used to speed up the query process. They are used to quickly locate the rows in a table that match the search condition.
|
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
|
|
|
CREATE INDEX idx_comments_content ON comments USING gin (content gin_trgm_ops);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_posts_title ON posts USING gin (title gin_trgm_ops);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_posts_tags ON posts USING gin (tags);
|
|
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_users_username ON users (username);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_posts_user_id ON posts (user_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_comments_post_id ON comments (post_id);
|
|
|
|
|
|
|