---
schema_version: "1"
id: a01bfd5f09605394f59c72236d2b9bd87bf98f97b28f1e0dbdad8651e612ba25
title: Best Practices for Optimizing Usage
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-dev/guides/best-practices-usage.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-dev/guide/best-practices-usage.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1593342e19f1c0d04b1786471f9eedf80097c4b6ced077b2eaeb0ce1aeea6ec4
products:
  - Data 360 Developer Guide
  - Data 360 Developer Documentation
---
# Best Practices for Optimizing Usage

To stay within your consumption credits, follow best practices to optimize your service and data usage.

Customer and Salesforce partners can follow these tips.

## Optimize Your Code for Best Performance

Write optimized code that’s inexpensive, such as queries. You can write SQL queries to fetch only the data that you need. Queries are preferable over GET API requests because they offer more flexibility in choosing the data that you want to retrieve. To write efficient queries, add a WHERE clause to filter the returned results and retrieve the smallest set of required records. Also, specify only the fields that you need in the SELECT statement.

For example, this query is efficient because it gets one Individual record for a specific Individual ID value.

Connect REST API resource:

```text
/ssot/query-sql
```

SQL query:

```json
{
    "sql": "select BirthDate__c, DataSourceId__c, DataSourceObjectId__c, ExternalRecordId__c,
        FirstName__c, GenderId__c, Id__c, InternalOrganizationId__c, LastName__c
        from Individual__dlm where Id__c='100470169'“
}
```

You can query data via Connect REST API. See the Query Library section in [Data Cloud Resources](https://developer.salesforce.com/docs/platform/connectapi/references/about-sample-api/about-connect-api.html) in the _Data Cloud Connect REST API Guide_. Or see [Query Data using Query API](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/data-cloud-query-api-reference/c360a-api-queryservices-overview.html) and [Query Customer Profile Information with Profile API](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/data-cloud-query-api-reference/c360a-api-profile-call-overview.html) in the _Data Cloud Query Guide_. Alternatively, you can use SOQL to query data. For more information, see [Data Cloud Query Profile Parameters](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_cdp_query.htm) in the _REST API Developer Guide_.

## Selective Data Ingestion

As part of your data ingestion strategy, ensure that you import relevant data records into Data 360 and that you don’t import more data than what’s needed. Sometimes it’s better to aggregate data before ingesting it rather than ingesting every data point, especially if not all attributes are relevant.

## Limit Test Data

When testing a custom app, limit the amount of testing data in the test org. Use a sample of records that’s sufficient to meet your functional testing needs.
