# Best Practices

### Use `recent` tables

If you only need recent/near-real-time data, then use the `recent` tables. These tables include the last 30 mins of data and are very fast to query.

### Improve performance with ORDER BY, LIMIT, and OFFSET

You can significantly improve the performance of your SQL query by using limits and offsets on indexed columns. For example to fetch data in chunks:

```
SELECT *
FROM taxi_trips
WHERE id > 0
ORDER BY id
LIMIT 1000000
OFFSET 0
```

```
SELECT *
FROM taxi_trips
WHERE id > 0
ORDER BY id
LIMIT 1000000
OFFSET 1000000
```

### Use the Apache Arrow API and SDKs

The [Apache Arrow API](https://github.com/spicehq/docs/blob/trunk/cloud/api/sql-query-api/apache-arrow-flight-api.md) uses Apache Arrow Flight to deliver results over a high-performance connection with no row limit.

SDKs like the [Python SDK](https://github.com/spicehq/docs/blob/trunk/cloud/sdks/python-sdk.md) always use the Arrow API, so they are a convenient way to access Spice data.

### Combine SQL with Python or other languages

Because the Arrow API makes it convenient to fetch data into pandas and NumPy formats, it's easy to use popular data science libraries and tools. Instead of doing everything in SQL, leverage both SQL and your client programming language to get the job done.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spice.ai/docs/reference/best-practices.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
