We introduce a static analysis and two program transformations for Datalog to circumvent performance issues that arise with the implementation of primitive predicates, notably in the framework of a large scale telecommunication application. To this effect, we introduce a new trace semantics for Datalog with a verified mechanization. This work can be seen as both a first step and a proof of concept for the creation of a full-blown library of verified Datalog optimizations, on top of an existing Coq/MathComp formalization of Datalog [5,14] towards the development of a realistic environment for certified data-centric applications. CCS Concepts: • Security and privacy → Logic and verification; • Theory of computation → Program analysis; • Networks → Network dynamics.