yesodweb / yesodweb/persistent

putMany is very expensive

Open
#1,282 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

We have a Postgres db which is filled doing bulk inserts and reaches up to 30GB. We used putMany in chunks of 1000 rows for this. We noticed that this check https://github.com/yesodweb/persistent/blob/master/persistent/Database/Persist/Sql/Orphan/PersistUnique.hs#L70 adds a very heavy toll and removing it makes everything drastically faster

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read persistent/Database/Persist/Sql/Orphan/PersistUnique.hs at line 70 and trace how the check is reached by putMany. Reproduce the reported bulk-insert workload against PostgreSQL, compare performance with and without the check, and identify the behavior-preserving change needed to reduce its cost. Done means the relevant behavior remains covered and the bulk-insert overhead is demonstrably lower.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.