Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Commit

Permalink
Optimized index
Browse files Browse the repository at this point in the history
  • Loading branch information
tahirmurata committed Oct 5, 2024
1 parent 7bf5ddd commit bfe4c8b
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,24 @@ CREATE TABLE exhibition_logs (
FOREIGN KEY (visitor_id) REFERENCES visitors(id)
);
-- Create indexes
CREATE INDEX idx_visitors_ip ON visitors(ip);
CREATE INDEX idx_visitors_id ON visitors(id);
CREATE INDEX idx_visitors_id_random ON visitors(id, random);
CREATE INDEX idx_nodes_id ON nodes(id);
CREATE INDEX idx_entry_logs_node_id_type ON entry_logs (node_id, type);
CREATE INDEX idx_nodes_key ON nodes(key);
CREATE INDEX idx_node_foods_food_id ON node_foods (food_id);
CREATE INDEX idx_nodes_ip ON nodes(ip);
CREATE INDEX idx_food_stall_logs_node_food_id ON food_stall_logs (node_food_id);
CREATE INDEX idx_exhibition_logs_node_id ON exhibition_logs (node_id);
CREATE INDEX idx_entry_logs_node_id_type_created_at ON entry_logs (node_id, type, created_at);
CREATE INDEX idx_food_stall_logs_node_food_id_created_at ON food_stall_logs(node_food_id, created_at);
CREATE INDEX idx_exhibition_logs_node_id_created_at ON exhibition_logs (node_id, created_at);
--
-- Visitors Table
CREATE INDEX idx_visitors_ip ON visitors (ip);
CREATE INDEX idx_visitors_id ON visitors (id);
CREATE INDEX idx_visitors_id_random ON visitors (id, random);
-- Nodes Table
CREATE INDEX idx_nodes_ip ON nodes (ip);
CREATE INDEX idx_nodes_key ON nodes (key);
-- EntryLogs Table
CREATE INDEX idx_entry_logs_visitor_id ON entry_logs (visitor_id);
CREATE INDEX idx_entry_logs_node_id ON entry_logs (node_id);
CREATE INDEX idx_entry_logs_type ON entry_logs (type);
CREATE INDEX idx_entry_logs_type_created_at ON entry_logs (type, created_at);
-- FoodStallLogs Table
CREATE INDEX idx_food_stall_logs_node_food_id ON food_stall_logs (node_food_id);
CREATE INDEX idx_food_stall_logs_node_food_id_created_at ON food_stall_logs (node_food_id, created_at);
-- ExhibitionLogs Table
CREATE INDEX idx_exhibition_logs_node_id ON exhibition_logs (node_id);
CREATE INDEX idx_exhibition_logs_node_id_created_at ON exhibition_logs (node_id, created_at);
-- NodeFoods Table
CREATE INDEX idx_node_foods_node_id ON node_foods (node_id);

0 comments on commit bfe4c8b

Please sign in to comment.