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

Have the option to use DELETE statements for Postgres to increase performance #126

Open
relfman-cmg opened this issue Jul 24, 2023 · 1 comment

Comments

@relfman-cmg
Copy link

Hi,

I have the a scenario for integration tests where each test clears the DB for approx 40 tables. It takes 200-300ms which adds up over multiple tests. The tables have barely any rows in them per each test, however when I had wrote a query with multiple DELETE FROM CASCADE statements it's ~30ms.

See this for more details: https://www.lob.com/blog/truncate-vs-delete-efficiently-clearing-data-from-a-postgres-table

It would be good to have the option to flip between TRUNCATE and DELETE depending if you have lots of rows or very little

@cervengoc
Copy link

cervengoc commented Sep 27, 2023

As far as I know TRUNCATE (at least in MS SQL) will fail when foreign key constraints are present, regardless of what the statement order is, so it probably should not be used.
(Sorry, I've justed checked that it's different in PG)

Overall, an approach could be to add an extension point for customizing/extending the generated delete statements, so one can kind of do whatever he wants.

It would also open the paths for other extension feature like PK snapshoting (see #122)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants