Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Indexes, statistics and execution plans in Protheus

Connects Protheus access with SQL Server execution-plan analysis.

Indexes, statistics and execution plans in ProtheusAdvPL
01 · OVERVIEW

Overview

DBAccess may translate ISAM operations to SQL; direct queries must still respect Protheus physical names, branch and logical deletion. A work-area order does not force the optimizer to use a particular physical index. SQL Server statistics describe distribution and inform cardinality estimates. An actual plan contains execution data because the query ran: capture requires permissions and cost assessment. Compare SQL, parameters, results, estimated/actual rows, reads and duration under equivalent conditions. The Microsoft instructions apply specifically to SQL Server, not generic database maintenance. (Sources: refs. 1–3.)

03 · PRACTICAL EXAMPLE

Commented example

// Diagnostic path: does not run SQL or change indexes.
// 1. Capture SQL/parameters without sensitive data.
// 2. Check physical names, branch and logical deletion.
// 3. Capture plan in an authorized environment; actual plans run the query.
// 4. Compare estimates, actual rows, reads and duration.
// 5. Repeat with equivalent results before proposing changes.
Expected result

Editorial procedure without a measured benchmark or promised performance gain. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not issue REBUILD or UPDATE STATISTICS automatically. Decisions depend on database, load, permissions and maintenance impact with DBA assessment.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Desenvolvendo queries no Protheus. Accessed on 2026-10-28.
  2. Microsoft. Statistics — SQL Server. Accessed on 2026-10-28.
  3. Microsoft. Display an actual execution plan. Accessed on 2026-10-28.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha