[Python] How to Efficiently Find Records Present in Table t1 but Not in t2 in DolphinDB

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    I have two structurally identical tables t1 and t2 in DolphinDB. I need to find all records that exist in t1 but not in t2, similar to a set difference operation in Python (set(t1) - set(t2)). Example Data

    // Table t1
    t1 = table(1 2 3 4 as id, `A`B`C`D as name)

    // Table t2
    t2 = table(2 3 5 as id, `B`C`E as name)


    Desired Output

    id | name
    ---|-----
    1 | A
    4 | D


    Attempted Approach I tried using a subquery with NOT IN:

    select * from t1 where id not in select id from t2


    This works for small datasets, but performance degrades significantly when tables exceed ~100 rows.

    Is there a more efficient way to achieve this in DolphinDB? Ideally, a solution optimized for larger datasets (e.g., using joins or built-in functions).Is there a more efficient way to achieve this in DolphinDB? Ideally, a solution optimized for larger datasets (e.g., using joins or built-in functions).

    Continue reading...

Compartilhe esta Página