Skip to content

Skip ip_address() for address objects in IPv6 inserts - #1166

Merged
joe-clickhouse merged 3 commits into
ClickHouse:mainfrom
patrick-immometrica:perf-ipv6-insert
Nov 10, 2026
Merged

joe-clickhouse merged 3 commits into
ClickHouse:mainfrom
patrick-immometrica:perf-ipv6-insert

Conversation

@patrick-immometrica

Copy link
Copy Markdown
Contributor

Summary

IPv6._write_column_binary calls ip_address(value) for every row, even when value is already an IPv6Address/IPv4Address. For an address object that's expensive: the constructors don't special-case address instances, so the object gets stringified and parsed again, and for an IPv6Address only after the IPv4Address attempt has raised.

This uses the object as is when it's already an address and only calls ip_address() for everything else (str, int, bytes). Output is byte-identical.

Nullable(IPv6), 200k rows, Python 3.14, Cython build:

input main this PR
IPv6Address 1056 ms 30 ms
IPv4Address 274 ms 32 ms
mixed v4/v6/None 525 ms 20 ms

Checklist

  • Covered by the existing test_network.py tests (address objects, IPv4-mapped, None, invalid strings)
  • CHANGELOG entry

@patrick-immometrica
patrick-immometrica marked this pull request as ready for review November 9, 2026 12:06
joe-clickhouse
joe-clickhouse previously approved these changes Nov 9, 2026

@joe-clickhouse joe-clickhouse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks.

Signed-off-by: Joe Spadola <joe.spadola@clickhouse.com>
@joe-clickhouse
joe-clickhouse merged commit 98b2991 into ClickHouse:main Nov 10, 2026
54 checks passed
@patrick-immometrica
patrick-immometrica deleted the perf-ipv6-insert branch November 10, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants