_total Search Parameter¶
Overview¶
The _total parameter controls whether and how the server calculates and returns the total count of matching resources in search results.
FHIR Specification¶
- _total - Control total count behavior
Values¶
| Value | Description |
|---|---|
accurate |
Return an accurate total count (default behavior) |
estimate |
Return an estimated count (currently returns accurate count) |
none |
Do not return a total count |
Usage¶
# Default behavior - returns accurate total
GET /Patient
# Explicitly request accurate total
GET /Patient?_total=accurate
# Skip total calculation (useful for performance on large datasets)
GET /Patient?_total=none
# Request estimated total (currently same as accurate)
GET /Patient?_total=estimate
Response Examples¶
With total (default or _total=accurate)¶
Without total (_total=none)¶
Performance Considerations¶
accurate: Server counts all matching resources. For small datasets, this has minimal impact.estimate: Currently returns the same as accurate. Future optimization may use sampling for large datasets.none: Skips including the total in the response. The server still performs the search but doesn't report the count.
Combining with Other Parameters¶
The _total parameter can be combined with:
- Pagination:
?_total=none&_count=10&_offset=20 - Sorting:
?_total=accurate&_sort=-birthDate - _elements/_summary:
?_total=none&_elements=name,birthDate - _include/_revinclude:
?_total=none&_include=Condition:subject
Use Cases¶
Performance optimization¶
When you only need results and don't care about the total count:
Pagination with known total¶
When you need accurate pagination information:
Quick data retrieval¶
Fetch first page quickly without counting all matches:
Notes¶
- When
_totalis not specified, the default behavior isaccurate - The
_summary=countparameter takes precedence and always returns a count-only bundle - Pagination links are still included regardless of
_totalsetting