mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 02:05:37 +08:00
Wraps the trust-level `action` filter in a `MATERIALIZED` CTE so Postgres resolves those (rare) rows first via the existing `index_staff_action_logs_on_action_and_id`, instead of mis-estimating the unestim-able regex filters and falling back to a full-table merge join over `target_user_id`... Same results, no new index and ~11× fewer buffers on the 1-year range (from 230k to 20k). | Range | baseline buffers | rewrite buffers | baseline cold | rewrite cold | |---|---:|---:|---:|---:| | 7 day | 12.4k | 12.4k | 30 ms | 32 ms | | 30 day | 12.8k | 12.8k | 29 ms | 32 ms | | 3 month | 231k | **14k** | 103 ms | **37 ms** (2.8×) | | 1 year | 231k | **20k** | 96 ms | **40 ms** (2.4×) | The better improvement would be to add an index on the user_history table. But I think we can avoid it for now. |
||
|---|---|---|
| .. | ||
| activity_by_category.rb | ||
| admin_logins.rb | ||
| associated_accounts_by_provider.rb | ||
| bookmarks.rb | ||
| consolidated_api_requests.rb | ||
| consolidated_page_views.rb | ||
| consolidated_page_views_browser_detection.rb | ||
| daily_engaged_users.rb | ||
| dau_by_mau.rb | ||
| emails.rb | ||
| flags.rb | ||
| flags_status.rb | ||
| likes.rb | ||
| mobile_visits.rb | ||
| moderator_warning_private_messages.rb | ||
| moderators_activity.rb | ||
| new_contributors.rb | ||
| notify_moderators_private_messages.rb | ||
| notify_user_private_messages.rb | ||
| post_edits.rb | ||
| posters_by_member_type.rb | ||
| posts.rb | ||
| profile_views.rb | ||
| signups.rb | ||
| site_traffic.rb | ||
| storage_stats.rb | ||
| suspicious_logins.rb | ||
| system_private_messages.rb | ||
| time_to_first_response.rb | ||
| top_countries_by_browser_pageviews.rb | ||
| top_ignored_users.rb | ||
| top_referred_topics.rb | ||
| top_referrers.rb | ||
| top_referrers_by_browser_pageviews.rb | ||
| top_traffic_sources.rb | ||
| top_uploads.rb | ||
| top_users_by_likes_received.rb | ||
| top_users_by_likes_received_from_a_variety_of_people.rb | ||
| top_users_by_likes_received_from_inferior_trust_level.rb | ||
| topic_view_stats.rb | ||
| topics.rb | ||
| topics_with_no_response.rb | ||
| trending_search.rb | ||
| trust_level_growth.rb | ||
| trust_level_pipeline.rb | ||
| user_flagging_ratio.rb | ||
| user_to_user_private_messages.rb | ||
| user_to_user_private_messages_with_replies.rb | ||
| users_by_trust_level.rb | ||
| users_by_type.rb | ||
| visits.rb | ||
| web_crawlers.rb | ||
| web_hook_events_daily_aggregate.rb | ||