Changes between Version 2 and Version 3 of ApplicationDevelopment


Ignore:
Timestamp:
09/29/25 14:24:16 (2 weeks ago)
Author:
221507
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ApplicationDevelopment

    v2 v3  
    1010 - Docker (recommended, especially for the DB)
    1111 - Native (no containers)
     12
     13
     14----
    1215     
     16== Indexes
     17
     18To optimize query performance and reduce full table scans as data volume grows, the following indexes were added based on real usage patterns in analytical queries, views, and joins.
     19
     20
     211. Most queries join trip and route using route_id, for example in company_performance_view, top_selling_routes_view, ticket statistics, and weighted usage reports. Without this index, every join would trigger a sequential scan of the trip table. With the index, the database can directly locate all trips for a given route.
     22
     23{{{
     24CREATE INDEX idx_trip_route_id ON trip(route_id);
     25}}}
     26
     27
     28----
     29
     30
     31
     32
     332. These two indexes accelerate lookups and joins involving route endpoints. They support queries that find trips between specific locations, which for our application is especially iseful to detect **subroutes**, one of the most important features. They're also useful in displaying routes with origin - destination metadata.
     34
     35
     36{{{
     37CREATE INDEX idx_route_from_location_id ON route(from_location_id);
     38CREATE INDEX idx_route_to_location_id ON route(to_location_id);
     39}}}
     40
     41
     42----
     43
     44
     453. Filtering by trip status (e.g., 'COMPLETED', 'NOT_STARTED') is common in **ticket statistics** and reporting queries. This index ensures that the database can filter relevant trips quickly instead of scanning the full trip table. It's especially important in analytical use cases and dashboards.
     46
     47
     48{{{
     49CREATE INDEX idx_trip_status ON trip(status);
     50}}}
     51
     52
     53----
     54
     55
     564. Views such as company_performance_view and top_selling_routes_view frequently join route and transport_organizer through transport_organizer_id. This index speeds up company-based route lookups, revenue calculations and per-organizer reporting. So, this index is useful for when we're calculating company metrics/revenue by organizer.
     57
     58
     59{{{
     60CREATE INDEX idx_route_transport_organizer_id ON route(transport_organizer_id);
     61}}}
     62
     63
     64
     65