Changes between Version 14 and Version 15 of AnalyticalStatisticalQuerying
- Timestamp:
- 09/30/25 20:44:20 (13 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AnalyticalStatisticalQuerying
v14 v15 249 249 }}} 250 250 251 == Results (Relational Algebra)==251 === Results (Relational Algebra) === 252 252 {{{ 253 253 T1 = σ(account_id = 300 ∧ date_purchased ≥ CURRENT_DATE - 3m)(ticket) … … 270 270 }}} 271 271 272 == Analysis (Optimizations)==272 === Analysis (Optimizations) === 273 273 * Push selection down: filter `ticket` by `account_id` and `date_purchased` before joins to reduce data early. 274 274 * Compute `weight` in a projection step before aggregation for clarity and efficiency. … … 278 278 - Foreign key indexes on `ticket.trip_id`, `trip.route_id`, and `route.{from_location_id, to_location_id, transport_organizer_id}`. 279 279 280 == Conclusion (Rewritten SQL)==280 === Conclusion (Rewritten SQL) === 281 281 {{{ 282 282 WITH route_scores AS ( … … 356 356 }}} 357 357 358 == Results (Relational Algebra)==358 === Results (Relational Algebra) === 359 359 {{{ 360 360 J1 = location ⨝ ticket (l.location_id = t.gets_off_location_id) … … 376 376 }}} 377 377 378 == Analysis (Optimizations)==378 === Analysis (Optimizations) === 379 379 * Push projections early: keep only `location_id`, `ticket_id`, `account_id`, `price`, and join keys before grouping. 380 380 * Apply the date filter (`past year`) explicitly in the `WHERE` clause on `ticket.date_purchased` (missing in original). … … 385 385 - Foreign keys on `trip.route_id`, `trip.transport_organizer_id`. 386 386 387 == Conclusion (Rewritten SQL)==387 === Conclusion (Rewritten SQL) === 388 388 {{{ 389 389 WITH destinations AS ( … … 450 450 }}} 451 451 452 == Results (Relational Algebra)==452 === Results (Relational Algebra) === 453 453 {{{ 454 454 J1 = route ⨝ transport_organizer … … 469 469 }}} 470 470 471 == Analysis (Optimizations)==471 === Analysis (Optimizations) === 472 472 * Push projections early to reduce carried attributes before aggregation. 473 473 * Join order: start with fact tables (`ticket`, `payment`) then join dimension tables (`trip`, `route`, `location`, `transport_organizer`). … … 477 477 - Foreign keys: `route.from_location_id`, `route.to_location_id`, `route.transport_organizer_id` 478 478 479 == Conclusion (Rewritten SQL)==479 === Conclusion (Rewritten SQL) === 480 480 {{{ 481 481 CREATE VIEW top_selling_routes_view AS