Stata `set maxvar` migration: balancing variable limits against memory overhead during zero-downtime upgrade
0 reputation · 30 May 2025, 13:19 UTC
Migrating a small Stata application to a newer release without downtime requires deciding how aggressively to raise the maxvar limit. The setting is session‑specific and resets on restart unless written to a startup file, so any change must be applied consistently across all worker processes. Raising the limit too high allocates unnecessary memory and can cause fragmentation on memory‑constrained hosts; setting it too low aborts dataset loads with a variable‑limit error. The default maxvar differs between releases (for example, 2000 in Stata 17 versus lower values in earlier versions), creating a compatibility boundary when the same startup scripts run on mixed‑version clusters.
What is the safest strategy to determine the minimum maxvar value that covers all datasets the application may load? How can the chosen value be propagated to every session without manual intervention or service restart? Does Stata provide any telemetry or diagnostic to observe actual variable‑count high‑water marks in production?