# Bug OP-18073 - APIv3: Totals are counted, even if not selected

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-18073

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | High |
| Module | API |
| Target versions | 16.6.0 |
| Observed in versions | 16.5.0 |
| Sprint | 16.6.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 16.5.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Jan Sandbrink |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Make an API call to a resource supporting [Signaling](https://www.openproject.org/docs/api/signaling/)
    
    1.  e.g. `/api/v3/work_packages/:id/available_relation_candidates`

2.  Make a select that does not include the `total` attribute (i.e. the total number of elements in the collection)
    
    1.  e.g. `/api/v3/work_packages/:id/available_relation_candidates?select=elements/id`

### What is the buggy behavior?

We query the database for the total number of elements anyways, even if it's not displayed anywhere.

### What is the expected behavior?

The database query for the total number of elements should just be performed, if it needs to be displayed.

### QA Note

The difference between expected and actual behaviour is only visible in response times for **large collections** (excluding the total should make the response faster) or by accessing the server logs.

We might want to consider skipping QA for this work package.
