←︎ Back to selected work Payroll forecasting optimization
Justworks
Worked inside an established Rails/PostgreSQL payroll product to bring expensive forecasting operations down from minutes to seconds.
PerformancePostgreSQLRailsData cleanup

Justworks
5-10+ minbefore optimization
secondsafter optimization
~60→︎120 GBdatabase growth during engagement
01 / ContextWhat I walked into
I joined an existing payroll/forecasting codebase where routine forecast operations could take five to ten minutes or longer. The database was growing quickly and data/model conventions around polymorphic associations had drifted over time.
02 / Engineering problemWhat had to be solved
Improve response time without treating the symptom as a single slow query. The work crossed production data, associations, schema behavior, application code and tests in a large codebase.
My contribution
THE WORK I OWNED
01Worked on query and schema-related optimization around payroll forecasting and related payroll flows.
02Corrected production polymorphic association data where model names had been stored inconsistently, and updated application code to follow the corrected conventions.
03Participated in team design discussions around changing the payroll/invoice association from one-to-many to many-to-many so historical invoices could be reused correctly in later payrolls.
04Handled the broad application/test impact of small association changes, where one data-model change could touch more than a hundred files.
05Fixed affected unit tests and documented remaining data-cleanup work for the next developer during handoff.
System view
HOW THE PIECES CONNECT
01Rails application
02Payroll domain
03PostgreSQL
04Sidekiq
05Polymorphic associations
06Forecasting queries
OutcomeThe forecasting/page operation that had taken five to ten minutes or more was brought down to seconds after the optimization and data-association cleanup work.
Technology
RubyRuby on RailsPostgreSQLSidekiqRSpec