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

Warn that TRUNCATEing many tables with Postgres can become slow #202

Merged
merged 1 commit into from
Jun 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/TestImport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ wipeDB app = runDBWithApp app $ do
tables <- getTables
sqlBackend <- ask

-- TRUNCATEing all tables is the simplest approach to wiping the database.
-- Should your application grow to hundreds of tables and tests,
-- switching to DELETE could be a substantial speedup.
-- See: https://github.com/yesodweb/yesod-scaffold/issues/201
let escapedTables = map (connEscapeName sqlBackend . DBName) tables
query = "TRUNCATE TABLE " ++ intercalate ", " escapedTables
rawExecute query []
Expand Down