# HTTP connection - caching, or flush data? Inconsistencies

**URL:** <https://community.cratedb.com/t/http-connection-caching-or-flush-data-inconsistencies/1743>\
**Category:** CrateDB\
**Created:** [March 30, 2024, 8:05pm UTC](https://community.cratedb.com/t/http-connection-caching-or-flush-data-inconsistencies/1743 "2024-03-30T20:05:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HughMacd](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hughmacd/32/1206_2.png) [@HughMacd](https://community.cratedb.com/u/HughMacd)\
**Post date:** [March 30, 2024, 8:05pm UTC](https://community.cratedb.com/t/http-connection-caching-or-flush-data-inconsistencies/1743/1 "2024-03-30T20:05:09Z")

</div>

Hi,

I have a table with a timestamp as the primary key.

I’ve discovered that if I do an INSERT immediately followed immediately by a SELECT, the newly inserted one isn’t listed.

I’m doing all of this using the python `crate` module.

For example, if I run the following SQL in immediate succession, I get nothing out.

```auto
$ INSERT INTO crate.temp (time, value) VALUES (1711829022368, 0.8540778019242715)
$ SELECT * FROM crate.temp
[]

```

Do I need to flush something along the way?

Thanks

EDIT: I’ve found that doing a 500ms pause after each query gives me the right output about 90% of the time. A 1s pause seems to be reliable. This is obviously not ideal, but it just adds about 60s to a script that runs once every 15 minutes, so it’s not a show-stopper.

---

<div class="post-metadata">

**Author:** ![amotl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/amotl/32/617_2.png) [@amotl](https://community.cratedb.com/u/amotl)\
**Post date:** [March 30, 2024, 8:18pm UTC](https://community.cratedb.com/t/http-connection-caching-or-flush-data-inconsistencies/1743/2 "2024-03-30T20:18:04Z")

</div>

Dear Hugh,

thank you for writing in.

> [@HughMacd](#):
>
> Do I need to flush something along the way?

If you want to flush manually, instantly and purposely, you will need to invoke the `REFRESH TABLE` statement to synchronize writes, because of CrateDB’s [eventual consistency](https://en.wikipedia.org/wiki/Eventual_consistency) properties. However, data also converges automatically after one second by default, see below.

```sql
REFRESH TABLE crate.temp;

```

> **[Storage and consistency](https://cratedb.com/docs/crate/reference/en/5.6/concepts/storage-consistency.html#consistency)**
>
> This document provides an overview on how CrateDB stores and distributes state across the cluster and what consistency and durability guarantees are provided. Table of contents Data storage, Atomicity at document level, Durability, Addressing...

> [@HughMacd](#):
>
> A 1s pause seems to be reliable.

That’s correct. By default, data automatically converges after 1000ms, but you can also adjust that on behalf of the `refresh_interval` table setting, to match your needs.

@hammerhead and @proddata also shared excellent details about this topic over here, including relevant pointers to the reference documentation. Enjoy reading, and don’t hesitate to come back with relevant questions.

- [Fundamentals of eventual consistency in CrateDB](https://community.cratedb.com/t/fundamentals-of-eventual-consistency-in-cratedb/1235)
- [CrateDB need timeout to see changes from insert/update/delete queries](https://community.cratedb.com/t/cratedb-need-timeout-to-see-changes-from-insert-update-delete-queries/726)
- [It takes longer to count tables where data is being inserted](https://community.cratedb.com/t/it-takes-longer-to-count-tables-where-data-is-being-inserted/1720)
- [SQL selects retrieve partial data](https://community.cratedb.com/t/sql-selects-retrieve-partial-data/1488)

With kind regards,  
Andreas.
