Raghu Koratagere
02/04/2025, 6:52 AMJoin related feasibility question:
I have,
• fact table leads_data (35M) rows and a dim table user_data (40M) rows
• leads_data.user_id needs to be joined with user_data.user_id to get user details
I can have filters on leads_data, but cannot restrict user_data as leads can have any of the 40M users stamped on it.
Issue: Loading full user_data (40M rows) into memory to perform HASH join is not possible
What is the correct way out. Pre-Joining is not so much of an option as I do have other child tables which are 1:N rows to lead_dataRaghu Koratagere
02/05/2025, 6:45 AMMayank
Raghu Koratagere
02/06/2025, 8:58 AM*partitioned hash joins*, *dynamic filters and hash exchanges.* I was hoping to achieve JOIN perf atleast as much as my existing system with PinotDBRaghu Koratagere
02/06/2025, 8:59 AMRaghu Koratagere
02/06/2025, 8:59 AMTrino version: 410 Fragment 0 [SINGLE] Output layout: [name, username] Output partitioning: SINGLE [] Output[columnNames = [name, user - user_id__username]] │ Layout: [name:varchar, username:varchar] │ Estimates: {rows: 1048575 (110.00MB), cpu: 0, memory: 0B, network: 0B} │ user - user_id__username := username └─ Limit[count = 1048575] │ Layout: [name:varchar, username:varchar] │ Estimates: {rows: 1048575 (110.00MB), cpu: 110.00M, memory: 0B, network: 0B} └─ LocalExchange[partitioning = SINGLE] │ Layout: [name:varchar, username:varchar] │ Estimates: {rows: 1048575 (110.00MB), cpu: 0, memory: 0B, network: 0B} └─ RemoteSource[sourceFragmentIds = [1]] Layout: [name:varchar, username:varchar] Fragment 1 [HASH] Output layout: [name, username] Output partitioning: SINGLE [] LimitPartial[count = 1048575] │ Layout: [name:varchar, username:varchar] │ Estimates: {rows: 1048575 (110.00MB), cpu: 110.00M, memory: 0B, network: 0B} └─ InnerJoin[criteria = ("user_id" = "id_1"), hash = [$hashvalue, $hashvalue_15], distribution = PARTITIONED] │ Layout: [name:varchar, username:varchar] │ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: 0B} │ Distribution: PARTITIONED │ dynamicFilterAssignments = {id_1 -> #df_390} ├─ RemoteSource[sourceFragmentIds = [2]] │ Layout: [name:varchar, user_id:varchar, $hashvalue:bigint] └─ LocalExchange[partitioning = HASH, hashColumn = [$hashvalue_15], arguments = ["id_1"]] │ Layout: [id_1:varchar, username:varchar, $hashvalue_15:bigint] │ Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B} └─ RemoteSource[sourceFragmentIds = [3]] Layout: [id_1:varchar, username:varchar, $hashvalue_16:bigint] Fragment 2 [SOURCE] Output layout: [name, user_id, $hashvalue_14] Output partitioning: HASH [user_id][$hashvalue_14] ScanFilterProject[table = hive-v2:homeservice:base_lead, dynamicFilters = {"user_id" = #df_390}] Layout: [name:varchar, user_id:varchar, $hashvalue_14:bigint] Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B} $hashvalue_14 := combine_hash(bigint '0', COALESCE("$operator$hash_code"("user_id"), 0)) user_id := user_id:string:REGULAR name := name:string:REGULAR Fragment 3 [SOURCE] Output layout: [id_1, username, $hashvalue_17] Output partitioning: HASH [id_1][$hashvalue_17] ScanProject[table = hive-v2:nobroker:user] Layout: [id_1:varchar, username:varchar, $hashvalue_17:bigint] Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B} $hashvalue_17 := combine_hash(bigint '0', COALESCE("$operator$hash_code"("id_1"), 0)) id_1 := id:string:REGULAR username := username:string:REGULAR creation_date_partitioned:bigint:PARTITION_KEY :: [[201403, 202502]]Raghu Koratagere
02/06/2025, 9:04 AM