Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Partitioning Protheus tables in the DBMS

SQL Server: sys.tables + sys.indexes + sys.partitions

Evaluates physical partitioning with metrics and Protheus compatibility.

Partitioning Protheus tables in the DBMSAdvPL
01 · OVERVIEW

Overview

In SQL Server, a partitioned table remains one logical entity with rows spread across partitions in the same database. Partition elimination depends on predicates and the chosen column; more partitions do not guarantee improvement. Aligned indexes and uniqueness have constraints that can conflict with ERP standard keys. This is not branch-sharing configuration or separate company tables. The query below inventories heaps/clustered indexes and approximate row counts only; it performs no DDL and does not certify a Protheus design. (Sources: refs. 1–3.)

02 · SYNTAX

Syntax

SQL Server: sys.tables + sys.indexes + sys.partitions
03 · PRACTICAL EXAMPLE

Commented example

-- SQL Server: user-visible metadata only; no DDL.
SELECT s.name AS schema_name,t.name AS table_name,i.name AS index_name,
       p.partition_number,p.rows AS approximate_rows
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id=t.schema_id
JOIN sys.indexes AS i ON i.object_id=t.object_id
JOIN sys.partitions AS p ON p.object_id=i.object_id AND p.index_id=i.index_id
WHERE t.is_ms_shipped=0 AND i.index_id IN (0,1)
ORDER BY s.name,t.name,p.partition_number;
Expected result

Lists visible partitions and approximate counts; an unpartitioned table also has partition 1. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Before structural changes, align DBA/TOTVS support, DBMS/DBAccess versions, dictionary updates, uniqueness, backup and rollback. Measure plans, I/O and concurrency under representative load. Do not change standard keys just to satisfy partitioning rules.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. Microsoft. Partitioned tables and indexes. Accessed on 2026-10-27.
  2. Microsoft. sys.partitions (Transact-SQL). Accessed on 2026-10-27.
  3. TOTVS. Desenvolvendo queries no Protheus. Accessed on 2026-10-27.
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