You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2086,6 +2086,50 @@ $schema->table('events')
2086
2086
2087
2087
TTL expressions are emitted verbatim; they must not be empty or contain semicolons. Dialects other than ClickHouse throw `UnsupportedException`.
2088
2088
2089
+
**Skip-index algorithms** — every ClickHouse index is a data-skipping index that accelerates WHERE pruning by letting the engine skip whole granules. Pick the algorithm that matches the column shape via the `algorithm` argument on `Table::index()`:
2090
+
2091
+
```php
2092
+
use Utopia\Query\Schema\ClickHouse\IndexAlgorithm;
2093
+
2094
+
$schema->table('events')
2095
+
->bigInteger('id')->primary()
2096
+
->string('user_id')
2097
+
->string('country')
2098
+
->string('text')
2099
+
// BloomFilter — high-cardinality strings with `=` / `IN` predicates
// No algorithm specified → defaults to `TYPE minmax GRANULARITY 3`
2106
+
->index(['id'])
2107
+
->create();
2108
+
2109
+
// CREATE TABLE `events` (..., INDEX `idx_user_id` `user_id` TYPE bloom_filter GRANULARITY 1, ...)
2110
+
```
2111
+
2112
+
The 6 algorithms are `MinMax`, `Set`, `BloomFilter`, `NgramBloomFilter`, `TokenBloomFilter`, `Inverted`. Algorithm-specific arguments are passed via `algorithmArgs` and rendered verbatim — supply them from trusted (developer-controlled) source. Other dialects ignore the ClickHouse-only `algorithm` / `algorithmArgs` / `granularity` arguments.
2113
+
2114
+
`MinMax` and `Inverted` take no parenthesised arguments in ClickHouse DDL — passing `algorithmArgs` for them throws `ValidationException`. Skip indexes can also be added via `ALTER TABLE … ADD INDEX` by calling `alter()` on the builder.
2115
+
2116
+
**Engine SETTINGS** — emit `SETTINGS k=v` after the TTL clause:
2117
+
2118
+
```php
2119
+
$schema->table('events')
2120
+
->bigInteger('id')->primary()
2121
+
->settings([
2122
+
'index_granularity' => 8192,
2123
+
'allow_nullable_key' => true, // booleans become 1/0
2124
+
])
2125
+
->create();
2126
+
2127
+
// CREATE TABLE `events` (...) ENGINE = MergeTree() ORDER BY (`id`)
Setting names must match `[A-Za-z_][A-Za-z0-9_]*`; string values are restricted to `[A-Za-z0-9_.\-+/]*`. Use ints / floats / booleans for everything else. Other dialects ignore the call.
0 commit comments