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

Truncate tables when running silk_clear_request_log #270

Merged
merged 2 commits into from
Feb 12, 2018

Conversation

albertyw
Copy link
Member

Fixes #239

This should make ./manage.py silk_clear_request_log run a lot faster by using TRUNCATE for non-sqlite databases. I believe that objects.all().delete() won't run TRUNCATE on these tables because of foreign key checks.

@albertyw albertyw requested a review from avelis February 11, 2018 10:35
@AuHau
Copy link

AuHau commented Feb 11, 2018

Just small comment regarding the FKs.

In Postgres you can truncate multiple tables with one command and if you specify all tables which have the FK dependencies just between each other (eq. all Silk tables), then you don't have to turn off the FK checks ;-)

I have been using this for some time:
TRUNCATE TABLE silk_profile, silk_response, silk_profile_queries, silk_request, silk_sqlquery;

I checked Postgres documentation and multiple-table truncation is possible since 8.1 version, so it should be safe ;-)

Unfortunately this is not possible in MySQL :-/

@AuHau
Copy link

AuHau commented Feb 11, 2018

Hmmm I just saw how the whole command is implemented and without bigger rewrite the previously mentioned technique is not really usable :-/ Damn... Well then it is just FYI :-D

But thanks for the PR! Lets hope it will be merged...

@albertyw
Copy link
Member Author

Merging this for now. This should probably be refactored and tested later.

@albertyw albertyw merged commit 879ba45 into master Feb 12, 2018
@albertyw albertyw deleted the optimize-clear-silk branch February 12, 2018 06:48
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

Successfully merging this pull request may close these issues.

2 participants