All technical cases

Professional experience at BrasilTec

Performance and security in a legacy system

PostgreSQL queries, SQL injection remediation, and an explicit distinction between production results and validation tests.

  • PHP
  • PostgreSQL
  • SQL
  • AppSec

Context and contribution

At BrasilTec, I worked on a multi-tenant ERP and B2B marketplace with legacy queries, integrations, and production-support needs. My work included SQL analysis and rewrites, index and configuration review, and remediation of a security flaw in a PHP flow.

This account presents aggregate results and technical decisions. Table names, customer data, and internal operational details are not needed to explain the contribution.

Change applied in production

A legacy query combined subqueries and sequence generation. I reorganized the calculation with a window function while preserving the schema. The recorded time for that query went from approximately 470 ms to 0.18 ms.

In the same PHP flow, I fixed the handling of a numeric identifier that allowed SQL injection. Performance and security were addressed within the same maintenance work. This does not mean the entire system became that many times faster or that the whole application was audited.

In a separate production task, PostgreSQL tuning took a polling query from 653 ms to 1.9 ms. The recorded cache hit ratio was 98.92%. These are observations of specific paths, not an overall SLA.

What remained in validation

In tests aimed at removing N+1 patterns, I observed up to 99.7% fewer queries. One flow went from 1.21 s to 47 ms, with zero discrepancies in a comparison of 65,000 products.

These values belong to validation. There is insufficient confirmation to present them as measured production results. Output comparison helps check equivalence on that dataset; it does not replace concurrency testing, edge cases, or post-deployment observation.

How to explain the result in review

I distinguish query time, query count, and request latency: they are different metrics. For a repeatable comparison, I record parameters, dataset size, execution plan, cache state, and repeated runs. This is the recommended protocol for new measurements; the available historical records do not include a complete percentile distribution.

The lesson is to optimize a path while preserving its behavior and explaining what the evidence supports. I do not extrapolate financial savings, revenue growth, or improvements for every user from a single query.

References and evidence