Optimizing UNION Queries: From 30s To Under 1s Report Generation Time
Debugging performance issues in reports led to a breakthrough: replacing WHERE field IN with WHERE EXISTS (SELECT 1 ...) improved query time from 30s to under 1s!
Senior Rails developer from Latvia. Avid gamer. Longevity enthusiast. #keto-dude
Debugging performance issues in reports led to a breakthrough: replacing WHERE field IN with WHERE EXISTS (SELECT 1 ...) improved query time from 30s to under 1s!
Wrap .first_or_create!/find_or_create_by! calls in retryable block to prevent race conditions. Use Retryable gem with on: [ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid] for a clean solution.
Participated in code challenge despite illness, focusing on Domain Query Interface & entity-based operations. Learned to optimize game state & debugging info for reproducibility.
Ruby's Lint/Void rule has an exception: when called via `super`, last expression is returned, not value passed. This can lead to unexpected behavior.
Optimizing import logic with buffered bulk updates: collect updates in a buffer, perform upsert_all when reaching batch_size, reducing DB roundtrip overhead and improving performance.
JOIN tables with LIKE operator using PSQL concatenation: INNER JOIN config_entries ON things.name LIKE config_entries.lookup_term || '%