AI / Apache Paimon Interview questions
How can you optimize primary key lookups using the bucket-key option?
By default, a primary key table buckets records by hashing the entire primary key. If your primary key has multiple columns but most lookups actually filter on just a subset of them, hashing the full key spreads matching rows across every bucket — forcing a scan of buckets that don't actually contain what you're filtering for.
CREATE TABLE orders ( order_id BIGINT, customer_id BIGINT, order_date STRING, amount DOUBLE, PRIMARY KEY (order_id, customer_id) NOT ENFORCED ) WITH ( 'bucket' = '16', 'bucket-key' = 'customer_id' );
Setting bucket-key to just the column(s) you actually filter by — here, customer_id — means every record for a given customer lands in the same bucket. A query filtering on customer_id can then prune straight to the relevant bucket instead of scanning all of them, which is a meaningful optimization when lookup patterns are known and consistent.
More Related questions...