citusdata / citusdata/postgresql-hll

Q: Evaluation cost of hll_empty()

Open
#157 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C
Stars
1.2k
Forks
115
PR merge metrics
No merged PRs in 30d

Description

I am looking to "upsert" `hll`'s in my database, using a traditional two stage query:

```sql
# Add an empty HLL if one doesn't exist
INSERT INTO counts(event_type, reference, count)
VALUES(:event_type, :reference, hll_empty())
ON CONFLICT DO NOTHING;

# Add to the HLL
UPDATE counts
SET count = hll_add(count, hll_hash_text(:event_id))
WHERE event_type = :event_type AND reference = :reference;
```

Given `hll_empty()` will be invoked on every query, even in the update case (i.e. before a conflict is identified), how cheap/expensive is that function to execute? The README mentions use of a sentinel value – is this sentinel value recalculated every call?

Should I be concerned with the evaluation of that function being a potential bottleneck compared to `hll_add` and `hll_hash_text`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.