Changes between Version 53 and Version 54 of QueryOptimization


Ignore:
Timestamp:
05/09/26 22:30:49 (2 weeks ago)
Author:
231027
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • QueryOptimization

    v53 v54  
    582582}}}
    583583
     584||= QUERY PLAN =||
     585||Nested Loop  (cost\=1.29..21.42 rows\=1 width\=131) (actual time\=0.104..0.105 rows\=0 loops\=1)||
     586||  ->  Nested Loop  (cost\=0.86..12.96 rows\=1 width\=113) (actual time\=0.103..0.105 rows\=0 loops\=1)||
     587||        ->  Nested Loop  (cost\=0.57..12.61 rows\=1 width\=82) (actual time\=0.103..0.104 rows\=0 loops\=1)||
     588||              ->  Index Scan using idx_ehr_user_id on "Event_Happening_Rating" ehr  (cost\=0.29..4.30 rows\=1 width\=74) (actual time\=0.103..0.103 rows\=0 loops\=1)||
     589||                    Index Cond: (user_id \= 1)||
     590||              ->  Index Scan using "Event_Happening_pkey" on "Event_Happening" eh  (cost\=0.29..8.30 rows\=1 width\=16) (never executed)||
     591||                    Index Cond: (event_happening_id \= ehr.event_happening_id)||
     592||        ->  Index Scan using "Event_pkey" on "Event" e  (cost\=0.29..0.35 rows\=1 width\=39) (never executed)||
     593||              Index Cond: (event_id \= eh.event_id)||
     594||  ->  Index Scan using "User_pkey" on "User" u  (cost\=0.43..8.45 rows\=1 width\=26) (never executed)||
     595||        Index Cond: (user_id \= 1)||
     596||Planning Time: 464.594 ms||
     597||Execution Time: 0.187 ms||
     598
    584599 * '''INSERT'''
    585600
     
    593608}}}
    594609
     610||= QUERY PLAN =||
     611||Insert on "Event_Happening_Rating"  (cost\=0.31..0.34 rows\=0 width\=0) (actual time\=0.521..0.522 rows\=0 loops\=1)||
     612||  ->  Subquery Scan on "*SELECT*"  (cost\=0.31..0.34 rows\=1 width\=60) (actual time\=0.122..0.123 rows\=1 loops\=1)||
     613||        ->  Result  (cost\=0.31..0.33 rows\=1 width\=52) (actual time\=0.119..0.120 rows\=1 loops\=1)||
     614||              InitPlan 1||
     615||                ->  Limit  (cost\=0.29..0.31 rows\=1 width\=8) (actual time\=0.114..0.115 rows\=1 loops\=1)||
     616||                      ->  Index Only Scan Backward using "Event_Happening_Rating_pkey" on "Event_Happening_Rating" "Event_Happening_Rating_1"  (cost\=0.29..478.37 rows\=17872 width\=8) (actual time\=0.113..0.113 rows\=1 loops\=1)||
     617||                            Heap Fetches: 6||
     618||Planning Time: 0.297 ms||
     619||Trigger for constraint fk_event_happening_rating_event_happening: time\=0.490 calls\=1||
     620||Trigger for constraint fk_event_happening_rating_user: time\=0.370 calls\=1||
     621||Execution Time: 1.444 ms||
     622
    595623 * '''UPDATE'''
    596624
     
    604632}}}
    605633
     634||= QUERY PLAN =||
     635||Update on "Event_Happening_Rating"  (cost\=0.29..4.31 rows\=0 width\=0) (actual time\=0.176..0.177 rows\=0 loops\=1)||
     636||  ->  Index Scan using idx_ehr_user_id on "Event_Happening_Rating"  (cost\=0.29..4.31 rows\=1 width\=42) (actual time\=0.039..0.042 rows\=1 loops\=1)||
     637||        Index Cond: (user_id \= 1)||
     638||        Filter: (event_happening_id \= 1)||
     639||Planning Time: 0.153 ms||
     640||Execution Time: 0.218 ms||
     641
    606642Без индекси, секое пребарување на оценките по корисник предизвикува непотребно оптоварување на меморијата преку Seq Scan. Индексирањето на user_id и event_happening_id обезбедува брза филтрација и поврзување на рејтинзите со соодветните термини на настаните.
    607643
     
    628664
    629665}}}
     666
     667||= QUERY PLAN =||
     668||Nested Loop  (cost\=1.00..476.51 rows\=1 width\=131) (actual time\=359.514..359.524 rows\=1 loops\=1)||
     669||  ->  Nested Loop  (cost\=0.57..468.06 rows\=1 width\=113) (actual time\=359.389..359.396 rows\=1 loops\=1)||
     670||        ->  Nested Loop  (cost\=0.29..467.71 rows\=1 width\=82) (actual time\=2.104..2.110 rows\=1 loops\=1)||
     671||              ->  Seq Scan on "Event_Happening_Rating" ehr  (cost\=0.00..459.40 rows\=1 width\=74) (actual time\=2.038..2.041 rows\=1 loops\=1)||
     672||                    Filter: (user_id \= 1)||
     673||                    Rows Removed by Filter: 17871||
     674||              ->  Index Scan using "Event_Happening_pkey" on "Event_Happening" eh  (cost\=0.29..8.30 rows\=1 width\=16) (actual time\=0.061..0.062 rows\=1 loops\=1)||
     675||                    Index Cond: (event_happening_id \= ehr.event_happening_id)||
     676||        ->  Index Scan using "Event_pkey" on "Event" e  (cost\=0.29..0.35 rows\=1 width\=39) (actual time\=357.279..357.280 rows\=1 loops\=1)||
     677||              Index Cond: (event_id \= eh.event_id)||
     678||  ->  Index Scan using "User_pkey" on "User" u  (cost\=0.43..8.45 rows\=1 width\=26) (actual time\=0.120..0.121 rows\=1 loops\=1)||
     679||        Index Cond: (user_id \= 1)||
     680||Planning Time: 31.049 ms||
     681||Execution Time: 359.600 ms||
    630682
    631683 * '''INSERT'''
     
    640692}}}
    641693
     694||= QUERY PLAN =||
     695||Insert on "Event_Happening_Rating"  (cost\=0.31..0.34 rows\=0 width\=0) (actual time\=0.482..0.483 rows\=0 loops\=1)||
     696||  ->  Subquery Scan on "*SELECT*"  (cost\=0.31..0.34 rows\=1 width\=60) (actual time\=0.117..0.119 rows\=1 loops\=1)||
     697||        ->  Result  (cost\=0.31..0.33 rows\=1 width\=52) (actual time\=0.115..0.115 rows\=1 loops\=1)||
     698||              InitPlan 1||
     699||                ->  Limit  (cost\=0.29..0.31 rows\=1 width\=8) (actual time\=0.110..0.111 rows\=1 loops\=1)||
     700||                      ->  Index Only Scan Backward using "Event_Happening_Rating_pkey" on "Event_Happening_Rating" "Event_Happening_Rating_1"  (cost\=0.29..484.37 rows\=17872 width\=8) (actual time\=0.108..0.108 rows\=1 loops\=1)||
     701||                            Heap Fetches: 4||
     702||Planning Time: 0.203 ms||
     703||Trigger for constraint fk_event_happening_rating_event_happening: time\=0.197 calls\=1||
     704||Trigger for constraint fk_event_happening_rating_user: time\=0.114 calls\=1||
     705||Execution Time: 0.842 ms||
     706
    642707 * '''UPDATE'''
    643708
     
    650715
    651716}}}
     717
     718||= QUERY PLAN =||
     719||Update on "Event_Happening_Rating"  (cost\=0.29..8.31 rows\=0 width\=0) (actual time\=0.021..0.022 rows\=0 loops\=1)||
     720||  ->  Index Scan using uq_rating_happening_user on "Event_Happening_Rating"  (cost\=0.29..8.31 rows\=1 width\=42) (actual time\=0.020..0.021 rows\=0 loops\=1)||
     721||        Index Cond: ((event_happening_id \= 1) AND (user_id \= 2))||
     722||Planning Time: 0.132 ms||
     723||Execution Time: 0.081 ms||
    652724
    653725== Анализа и оптимизација на `Event_Overall_Ratings`