Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qe: fix pathological behaviour with many @uniques #4179

Merged
merged 1 commit into from
Aug 31, 2023
Merged

Commits on Aug 31, 2023

  1. qe: fix pathological behaviour with many @Uniques

    The quaint AST lets users keep track of unique index definitions in
    tables in order to generate `MERGE` statements in SQL Server.
    
    The SQL query connector diligently adds every unique index to the table
    definitions in the `AsTable` implementation for models.
    
    The concrete method used to add the indexes is
    `Table::add_unique_index()`. Its space complexity is `O(n!)` on the
    number of unique indexes on a model, which quickly leads to
    high memory usage, then hanging and out-of-memory errors.
    
    See the inline comment in the commit for more details on what happened
    exactly, and how this commit fixes the problem. The included regression
    test would consistently take multiple minutes, then OOM on a fast
    desktop machine with 32GB of RAM before the fix.
    
    closes prisma/prisma#20799
    tomhoule committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    8e8ab87 View commit details
    Browse the repository at this point in the history