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

Request.objects.all().delete() is dangerous #711

Open
moonsikpark opened this issue Jun 4, 2024 · 3 comments · May be fixed by #712
Open

Request.objects.all().delete() is dangerous #711

moonsikpark opened this issue Jun 4, 2024 · 3 comments · May be fixed by #712

Comments

@moonsikpark
Copy link

django-silk/silk/models.py

Lines 167 to 170 in 1cb4623

# Make sure we can delete everything if needed by settings
if target_count <= 0:
cls.objects.all().delete()
return

If you call all() on a table with many rows, it will retrieve all the data at once, which will likely result in out-of-memory (OOM) errors.

As a workaround, make sure to set the SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT very low (0.01 for example so it runs every 10_000 requests) and the SILKY_MAX_RECORDED_REQUESTS high (100_000 or more).

This way, the chances of running into this issue are much smaller (but still possible, depending on your load).

An even better workaround is to set SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT to 0 and run the silky.Request.garbage_collect(force=True) method in a scheduled task through celery.

Originally posted by @okke-formsma in #265 (comment)

I previously used Celery to call this function to avoid deadlock, as suggested in the referenced comment. However, due to OOM errors, our scheduler failed to clear the database, leading to excessive database usage.

I recommend setting a limit and deleting the rows recursively instead. I will submit a pull request to address this issue.

@albertyw
Copy link
Member

If you call all() on a table with many rows, it will retrieve all the data at once

I don't think that's true. It will retrieve data from the data if it is evaluated (e.g. through print() or otherwise). In this case, .all().delete() will issue a DELETE FORM <TABLE> without actually retrieving data so there should be no OOM in your python application.

Your pull request seems to tackle a different problem - since django-silk may be continually profiling and writing new rows into the database, it may conflict with DELETE operation unless the rows to be deleted are separate from newly written rows, hence the deadlock issues discussed in #265 and #294.

@moonsikpark
Copy link
Author

moonsikpark commented Jun 10, 2024

@albertyw I've thought like so, but no, django loads all to db because it needs to cascade delete related models.

The fix might also fix the deadlock problem.

The below is the raw SQL when I called Request.objects.all().delete().

SELECT "silk_request"."id", "silk_request"."path", "silk_request"."query_params", "silk_request"."raw_body", "silk_request"."body", "silk_request"."method", "silk_request"."start_time", "silk_request"."view_name", "silk_request"."end_time", "silk_request"."time_taken", "silk_request"."encoded_headers", "silk_request"."meta_time", "silk_request"."meta_num_queries", "silk_request"."meta_time_spent_queries", "silk_request"."pyprofile", "silk_request"."prof_file", "silk_request"."num_sql_queries" FROM "silk_request"
SELECT "silk_sqlquery"."id" FROM "silk_sqlquery" WHERE "silk_sqlquery"."request_id" IN ('bfce0b27-d37b-4a59-ac5e-d8bc0a4a77e2', 'd9669f6a-bbdc-4004-a49b-4e3820b1f203', '162ca2f1-07f0-4c88-94d9-44de3b939761', '9c8b6f15-2076-427e-835b-2110a20ad0d4', 'ad4a163b-f562-4173-aff1-37b936885e15', 'b149a155-8a3e-445e-b754-77c075f87c9d', 'bc314ea2-7cd5-48b5-b86e-ea6180390951', '812558b9-b3c2-4638-9432-146304a85bc3', '91bda11b-c416-472d-887b-22f700e39cbd', '82677a6c-eb15-4dd3-a5d8-a2e5c07fdd7f', '07772c38-44ad-41ca-8cba-04b07cccbf92', 'a8794d87-55bd-45ef-9281-bef4fc4302c6', '95893668-b748-4eb1-9174-fae8c319811f', 'd19b3211-190f-4b1a-a3ba-f8abfc601020', '466d5aa7-6b1a-4f29-9513-151445674eb3', '36a6d940-7b8f-422f-af18-0cf87517fa24', '3d0ddfe7-f213-406e-a4f0-62480d1be236', 'a0b5fa34-e2d3-4e3f-b9d7-7b29a4ec94be', 'd14fa877-dc20-4f12-98fb-d20c877895ff', '74fb3d22-fd98-4886-b40f-e31cf7007467', '142a00b8-b209-4c13-9265-8d8dbeaff546', '14c2d3c7-ab02-4968-bb4a-a6df560dbf5a', '2d81712d-7592-4d48-8373-a8c8e6465f9b', '74286415-0269-4b00-b1d2-9d5d9483f472', '30b321de-c44b-478b-85a0-92003c16adfe', '587c83a2-961f-4186-8616-3ed9a1fb0c22', 'c7088c65-c870-4893-9a92-169689da7486', '1eb61143-aff8-414c-bcd9-101d1f56d281', '3135780b-e1d4-4743-bd11-c5dcaa827858', '2e78bff1-361e-4716-9803-83e8073c6406', '3fc6e6b6-2677-4da1-ab01-1c5cd7d974d8', 'd0e1090b-1e6b-46c1-a719-3dd61760ad56', '764df748-58e8-47fb-a905-5cab024b4588', '73c27ea5-af89-425d-b05b-0552d72c8951', '07309f2d-15b9-4088-b274-87f5c7f6663f', '02ec451a-f08b-4561-be70-b0b1ef839990', '9531b4b4-6d16-4d0c-8a26-9831406b630a', 'a4b84d22-b857-4679-96e6-41d6133f6679', '0af0bee2-f96e-4a8c-b147-d5075a8e694c', '97adef41-54ab-45da-8dec-091bc94cdc13', 'f216b9bc-5bc9-4632-85d9-ab62997e4002', 'fbb23448-0d11-4dd0-ac3f-5c119732d54b', '3aa74cc6-fefb-448a-8d72-5b507bf5a22c', '357d84c9-9bfd-4ecc-991a-7d01db60c883', 'f46f72e2-9fac-4a11-a9dc-aaf5398988d1', 'ecc2cbb1-3c82-4c8f-8718-b3e3e2fa2fbd', 'dc017676-e57d-4fa8-9e40-1b180f9320cb', '32482e7c-fb25-44bd-8b9b-478b4e9448d6', 'f1c20bcb-299a-4889-b12a-47bac3067f7b', '10411bb8-5a5e-4f61-ba54-196b273dca8e', '70f119c5-8f3a-48e2-a7d7-1c0d1ba9899c', '5099b115-b556-48d6-b983-29975a1f352b', '40209e30-d160-439c-8471-39c2c70ff884', '2c4613b5-4a53-4235-b8a7-a16ab86a940c', '7a1f4db7-981e-4b0d-93a8-9b08a42f472d', '907cc0e7-af06-44db-b4a4-cbba3cb213fe', 'be63bea9-b62d-428b-bd49-594fdd5d83c1', 'fd6f1391-28a2-4800-a942-1b46a9180ba2', 'c32ddb06-8345-457b-83b5-3955a5938e6e', 'bc783705-7601-43e4-9078-5aee87b4ec03', '1f288e43-91b0-4b35-bfe7-60d2d6ff69da', 'f6d95fdd-872f-43ad-a6f3-82f5d5ab3336', 'fe41ace5-eac8-40cb-972b-015537fceed6', 'd1e4d336-a764-400d-8ca6-7414834fa1b2', 'a17bcce5-bceb-4e66-ab22-503aaae8a3ef', 'd5f28ee4-afcf-4000-a90d-fa3d38586da5', '00ab20db-226f-4c8c-9778-0f5689dd5417', 'a35d409f-3492-4388-a06c-83a97b766454', '885af7e6-8a64-45e3-a7d0-c1c5dc89c75e', '32ef642a-2dce-4374-8332-887b2359dad8', 'ee31569e-8cdd-4005-8498-48380f539760', '6fc29edb-4a7f-42d7-a6b8-e38d6dcb4b2d', 'e6938bfd-c485-46a8-88e7-6716c63705a8', 'd97b5ff6-d567-43a5-a4fe-c2aa5cd75a98', 'ad494df0-ed01-4ec2-badd-e23eee116bd2', 'aca29ef7-13a5-4b76-adea-1bb15ae006d4', '467161ff-e53f-4a16-baf6-8868c2ef52ff', 'fd678e2c-0ecb-41ae-9340-8c3234f77dbf', 'fdc52571-a4d3-4033-b6c0-a88fc1841db8', 'bde89d72-f464-4126-bfd5-4d148b509699', '1ea4b6fc-39ba-4668-9457-e8ffbe01bdfa', '9a9a3010-1caa-420c-801c-c7b4ba224f8b', '8d672700-710f-41a1-bcc7-f81f94e2ba25', 'bd44d7a7-37eb-4ebb-8d20-5c578cf8c60d', 'f712d2d8-f228-466c-905d-d0aefc25b723', 'ccb2e482-c304-46da-a88c-dc9a116cbcf2', 'f208238f-b069-4212-aafe-61103a7e2beb', '62a9d851-ce6a-4565-afc0-e243f23958f3', '236a6816-1133-4779-ad55-d02ff7fe3081', 'b1846089-9168-4cbe-8161-a0ab75e75f98', 'd2a20686-63d2-4027-ba7f-410b64aafe2f', '2a68e29a-3737-4f1c-b52d-abb9ece1af56', '04e572b9-3b16-4715-a3a2-932f52fa29a5', '4a9ec976-d360-4adb-bc8e-aa0599119e05', '81d2a797-eacf-4ee1-b4ab-7c1d440e7a97', 'd00be5b4-7704-45d4-a977-2645db0240f4', 'a21fa536-95b8-482c-b113-d3163627e210', 'bee6cee4-f314-4ca1-92ba-400c777de9c8', '1c11d65a-17de-40b3-86ab-dd71fde955f4', '771793e5-7c17-4ece-ab22-d13f9da42b18', 'ff09f5e6-031f-47cd-a61f-705cb11c821e', '2b6aead1-9ac3-47a3-bab4-fdacc6c3f80d', '9991700d-694b-41a4-98b0-4dd5b6232dee', '711ad65d-8edc-411f-aa49-67803096af4c', '18e3bfe6-a067-408f-bba9-d00f65a870cd', '701875e9-0bc4-4009-92f9-6d292bb6c511', '394e1c72-5e82-4433-bc8d-75b5e077488d', '4733f7f3-71b2-42e7-9c45-ff8d51497c13')
SELECT "silk_profile"."id" FROM "silk_profile" WHERE "silk_profile"."request_id" IN ('bfce0b27-d37b-4a59-ac5e-d8bc0a4a77e2', 'd9669f6a-bbdc-4004-a49b-4e3820b1f203', '162ca2f1-07f0-4c88-94d9-44de3b939761', '9c8b6f15-2076-427e-835b-2110a20ad0d4', 'ad4a163b-f562-4173-aff1-37b936885e15', 'b149a155-8a3e-445e-b754-77c075f87c9d', 'bc314ea2-7cd5-48b5-b86e-ea6180390951', '812558b9-b3c2-4638-9432-146304a85bc3', '91bda11b-c416-472d-887b-22f700e39cbd', '82677a6c-eb15-4dd3-a5d8-a2e5c07fdd7f', '07772c38-44ad-41ca-8cba-04b07cccbf92', 'a8794d87-55bd-45ef-9281-bef4fc4302c6', '95893668-b748-4eb1-9174-fae8c319811f', 'd19b3211-190f-4b1a-a3ba-f8abfc601020', '466d5aa7-6b1a-4f29-9513-151445674eb3', '36a6d940-7b8f-422f-af18-0cf87517fa24', '3d0ddfe7-f213-406e-a4f0-62480d1be236', 'a0b5fa34-e2d3-4e3f-b9d7-7b29a4ec94be', 'd14fa877-dc20-4f12-98fb-d20c877895ff', '74fb3d22-fd98-4886-b40f-e31cf7007467', '142a00b8-b209-4c13-9265-8d8dbeaff546', '14c2d3c7-ab02-4968-bb4a-a6df560dbf5a', '2d81712d-7592-4d48-8373-a8c8e6465f9b', '74286415-0269-4b00-b1d2-9d5d9483f472', '30b321de-c44b-478b-85a0-92003c16adfe', '587c83a2-961f-4186-8616-3ed9a1fb0c22', 'c7088c65-c870-4893-9a92-169689da7486', '1eb61143-aff8-414c-bcd9-101d1f56d281', '3135780b-e1d4-4743-bd11-c5dcaa827858', '2e78bff1-361e-4716-9803-83e8073c6406', '3fc6e6b6-2677-4da1-ab01-1c5cd7d974d8', 'd0e1090b-1e6b-46c1-a719-3dd61760ad56', '764df748-58e8-47fb-a905-5cab024b4588', '73c27ea5-af89-425d-b05b-0552d72c8951', '07309f2d-15b9-4088-b274-87f5c7f6663f', '02ec451a-f08b-4561-be70-b0b1ef839990', '9531b4b4-6d16-4d0c-8a26-9831406b630a', 'a4b84d22-b857-4679-96e6-41d6133f6679', '0af0bee2-f96e-4a8c-b147-d5075a8e694c', '97adef41-54ab-45da-8dec-091bc94cdc13', 'f216b9bc-5bc9-4632-85d9-ab62997e4002', 'fbb23448-0d11-4dd0-ac3f-5c119732d54b', '3aa74cc6-fefb-448a-8d72-5b507bf5a22c', '357d84c9-9bfd-4ecc-991a-7d01db60c883', 'f46f72e2-9fac-4a11-a9dc-aaf5398988d1', 'ecc2cbb1-3c82-4c8f-8718-b3e3e2fa2fbd', 'dc017676-e57d-4fa8-9e40-1b180f9320cb', '32482e7c-fb25-44bd-8b9b-478b4e9448d6', 'f1c20bcb-299a-4889-b12a-47bac3067f7b', '10411bb8-5a5e-4f61-ba54-196b273dca8e', '70f119c5-8f3a-48e2-a7d7-1c0d1ba9899c', '5099b115-b556-48d6-b983-29975a1f352b', '40209e30-d160-439c-8471-39c2c70ff884', '2c4613b5-4a53-4235-b8a7-a16ab86a940c', '7a1f4db7-981e-4b0d-93a8-9b08a42f472d', '907cc0e7-af06-44db-b4a4-cbba3cb213fe', 'be63bea9-b62d-428b-bd49-594fdd5d83c1', 'fd6f1391-28a2-4800-a942-1b46a9180ba2', 'c32ddb06-8345-457b-83b5-3955a5938e6e', 'bc783705-7601-43e4-9078-5aee87b4ec03', '1f288e43-91b0-4b35-bfe7-60d2d6ff69da', 'f6d95fdd-872f-43ad-a6f3-82f5d5ab3336', 'fe41ace5-eac8-40cb-972b-015537fceed6', 'd1e4d336-a764-400d-8ca6-7414834fa1b2', 'a17bcce5-bceb-4e66-ab22-503aaae8a3ef', 'd5f28ee4-afcf-4000-a90d-fa3d38586da5', '00ab20db-226f-4c8c-9778-0f5689dd5417', 'a35d409f-3492-4388-a06c-83a97b766454', '885af7e6-8a64-45e3-a7d0-c1c5dc89c75e', '32ef642a-2dce-4374-8332-887b2359dad8', 'ee31569e-8cdd-4005-8498-48380f539760', '6fc29edb-4a7f-42d7-a6b8-e38d6dcb4b2d', 'e6938bfd-c485-46a8-88e7-6716c63705a8', 'd97b5ff6-d567-43a5-a4fe-c2aa5cd75a98', 'ad494df0-ed01-4ec2-badd-e23eee116bd2', 'aca29ef7-13a5-4b76-adea-1bb15ae006d4', '467161ff-e53f-4a16-baf6-8868c2ef52ff', 'fd678e2c-0ecb-41ae-9340-8c3234f77dbf', 'fdc52571-a4d3-4033-b6c0-a88fc1841db8', 'bde89d72-f464-4126-bfd5-4d148b509699', '1ea4b6fc-39ba-4668-9457-e8ffbe01bdfa', '9a9a3010-1caa-420c-801c-c7b4ba224f8b', '8d672700-710f-41a1-bcc7-f81f94e2ba25', 'bd44d7a7-37eb-4ebb-8d20-5c578cf8c60d', 'f712d2d8-f228-466c-905d-d0aefc25b723', 'ccb2e482-c304-46da-a88c-dc9a116cbcf2', 'f208238f-b069-4212-aafe-61103a7e2beb', '62a9d851-ce6a-4565-afc0-e243f23958f3', '236a6816-1133-4779-ad55-d02ff7fe3081', 'b1846089-9168-4cbe-8161-a0ab75e75f98', 'd2a20686-63d2-4027-ba7f-410b64aafe2f', '2a68e29a-3737-4f1c-b52d-abb9ece1af56', '04e572b9-3b16-4715-a3a2-932f52fa29a5', '4a9ec976-d360-4adb-bc8e-aa0599119e05', '81d2a797-eacf-4ee1-b4ab-7c1d440e7a97', 'd00be5b4-7704-45d4-a977-2645db0240f4', 'a21fa536-95b8-482c-b113-d3163627e210', 'bee6cee4-f314-4ca1-92ba-400c777de9c8', '1c11d65a-17de-40b3-86ab-dd71fde955f4', '771793e5-7c17-4ece-ab22-d13f9da42b18', 'ff09f5e6-031f-47cd-a61f-705cb11c821e', '2b6aead1-9ac3-47a3-bab4-fdacc6c3f80d', '9991700d-694b-41a4-98b0-4dd5b6232dee', '711ad65d-8edc-411f-aa49-67803096af4c', '18e3bfe6-a067-408f-bba9-d00f65a870cd', '701875e9-0bc4-4009-92f9-6d292bb6c511', '394e1c72-5e82-4433-bc8d-75b5e077488d', '4733f7f3-71b2-42e7-9c45-ff8d51497c13')
BEGIN
DELETE FROM "silk_profile_queries" WHERE "silk_profile_queries"."sqlquery_id" IN (122501, 122502, 122503, 122504, 122505, 122506, 122507, 122522, 122508, 122509, 122510, 122511, 122512, 122513, 122514, 122515, 122516, 122517, 122518, 122519, 122520, 122521, 122536, 122537, 122523, 122524, 122525, 122526, 122527, 122528, 122529, 122530, 122531, 122532, 122533, 122534, 122535, 122543, 122544, 122545, 122538, 122539, 122540, 122541, 122542, 122550, 122551, 122552, 122546, 122547, 122548, 122549, 122553, 122554, 122555, 122556, 122557, 122558, 122559, 122560, 122561, 122562, 122563, 122571, 122564, 122565, 122566, 122567, 122568, 122569, 122570, 122599, 122572, 122573, 122574, 122575, 122576, 122577, 122578, 122579, 122580, 122581, 122582, 122583, 122584, 122585, 122586, 122587, 122588, 122589, 122590, 122591, 122592, 122593, 122594, 122595, 122596, 122597, 122598, 122606, 122600, 122601, 122602, 122603, 122604, 122605, 122607, 122608, 122609, 122610, 122611, 122612, 122613, 122614, 122615, 122616, 122617, 122618, 122619, 122620, 122621, 122622, 122623, 122624, 122625, 122626, 122627, 122628, 122629, 122630, 122631, 122632, 122633, 122634, 122635, 122636, 122637, 122638, 122639, 122640, 122655, 122656, 122641, 122642, 122643, 122644, 122645, 122646, 122647, 122648, 122649, 122650, 122651, 122652, 122653, 122654, 122662, 122663, 122657, 122658, 122659, 122660, 122661, 122669, 122670, 122671, 122664, 122665, 122666, 122667, 122668, 122672, 122673, 122674, 122675, 122676, 122677, 122678, 122679, 122680, 122681, 122682, 122690, 122683, 122684, 122685, 122686, 122687, 122688, 122689, 122691, 122692, 122693, 122694, 122695, 122696, 122697, 122698, 122699, 122700, 122701, 122702, 122703, 122704, 122705, 122706, 122707, 122708, 122709, 122710, 122711, 122712, 122713, 122714, 122715, 122716, 122717, 122718, 122719, 122720, 122721, 122722, 122723, 122724, 122725, 122726, 122727, 122728, 122729, 122730, 122731, 122732, 122733, 122734, 122735, 122736, 122737, 122738, 122739, 122740, 122741, 122742, 122743, 122744, 122745, 122760, 122761, 122762, 122746, 122747, 122748, 122749, 122750, 122751, 122752, 122753, 122754, 122755, 122756, 122757, 122758, 122759, 122767, 122768, 122763, 122764, 122765, 122766, 122769, 122770, 122771, 122772, 122773, 122774, 122775, 122776, 122777, 122778, 122779, 122780, 122781, 122782, 122783, 122784, 122785, 122786, 122787, 122816, 122788, 122789, 122790, 122791, 122792, 122793, 122794, 122795, 122796, 122797, 122798, 122799, 122800, 122801, 122802, 122803, 122804, 122805, 122806, 122807, 122808, 122809, 122810, 122811, 122812, 122813, 122814, 122815, 122817, 122818, 122819, 122820, 122821, 122822, 122823, 122824, 122825, 122826, 122827, 122828, 122829, 122830, 122831, 122832, 122833, 122834, 122835, 122836, 122837, 122838, 122839, 122840, 122841, 122842, 122843, 122844, 122845, 122846, 122847, 122848, 122849, 122850, 122851, 122852, 122853, 122854, 122855, 122856, 122857, 122858, 122859, 122860, 122861, 122862, 122863, 122864, 122865, 122866, 122867, 122868, 122869, 122870, 122871, 122879, 122872, 122873, 122874, 122875, 122876, 122877, 122878, 122893, 122880, 122881, 122882, 122883, 122884, 122885, 122886, 122887, 122888, 122889, 122890, 122891, 122892, 122907, 122908, 122909, 122894, 122895, 122896, 122897, 122898, 122899, 122900, 122901, 122902, 122903, 122904, 122905, 122906, 122914, 122915, 122916, 122910, 122911, 122912, 122913, 122917, 122918, 122919, 122920, 122921, 122922, 122923, 122924, 122925, 122926, 122927, 122935, 122928, 122929, 122930, 122931, 122932, 122933, 122934, 122956, 122936, 122937, 122938, 122939, 122940, 122941, 122942, 122943, 122944, 122945, 122946, 122947, 122948, 122949, 122950, 122951, 122952, 122953, 122954, 122955, 122957, 122958, 122959, 122960, 122961, 122962, 122963, 122964, 122965, 122966, 122967, 122968, 122969, 122970, 122971, 122972, 122973, 122974, 122975, 122976, 123005, 123006, 122977, 122978, 122979, 122980, 122981, 122982, 122983, 122984, 122985, 122986, 122987, 122988, 122989, 122990, 122991, 122992, 122993, 122994, 122995, 122996, 122997, 123012, 123013, 123014, 122998, 122999, 123000, 123001, 123002, 123003, 123004, 123019, 123007, 123008, 123009, 123010, 123011, 123015, 123016, 123017, 123018, 123020, 123021, 123022, 123023, 123024, 123025, 123040, 123041, 123026, 123027, 123028, 123029, 123030, 123031, 123032, 123033, 123034, 123035, 123036, 123037, 123038, 123039, 123047, 123048, 123042, 123043, 123044, 123045, 123046, 123054, 123055, 123056, 123049, 123050, 123051, 123052, 123053, 123057, 123058, 123059, 123060, 123061, 123062, 123063, 123064, 123065, 123066, 123067, 123075, 123068, 123069, 123070, 123071, 123072, 123073, 123074, 123082, 123076, 123077, 123078, 123079, 123080, 123081, 123096, 123097, 123083, 123084, 123085, 123086, 123087, 123088, 123089, 123090, 123091, 123092, 123093, 123094, 123095, 123098, 123099, 123100, 123101, 123102, 123103, 123104, 123105, 123106, 123107, 123108, 123109, 123110, 123111, 123112, 123113, 123114, 123115, 123116, 123124, 123117, 123118, 123119, 123120, 123121, 123122, 123123, 123145, 123125, 123126, 123127, 123128, 123129, 123130, 123131, 123132, 123133, 123134, 123135, 123136, 123137, 123138, 123139, 123140, 123141, 123142, 123143, 123144, 123152, 123153, 123146, 123147, 123148, 123149, 123150, 123151, 123166, 123167, 123154, 123155, 123156, 123157, 123158, 123159, 123160, 123161, 123162, 123163, 123164, 123165, 123168, 123169, 123170, 123171, 123172, 123173, 123174, 123175, 123176, 123177, 123178, 123179, 123180, 123181, 123182, 123183, 123184, 123185, 123186, 123187, 123188, 123189, 123190, 123191, 123192, 123193, 123194, 123195, 123196, 123197, 123198, 123199, 123200, 123208, 123209, 123210, 123201, 123202, 123203, 123204, 123205, 123206, 123207, 123229, 123211, 123212, 123213, 123214, 123215, 123216, 123217, 123218, 123219, 123220, 123221, 123222, 123223, 123224, 123225, 123226, 123227, 123228, 123236, 123237, 123230, 123231, 123232, 123233, 123234, 123235, 123238, 123239, 123240, 123241, 123242, 123243, 123244, 123245, 123246, 123247, 123248, 123249, 122494, 122495, 122496, 122497, 122498, 122499, 122500)
DELETE FROM "silk_response" WHERE "silk_response"."request_id" IN ('bfce0b27-d37b-4a59-ac5e-d8bc0a4a77e2', 'd9669f6a-bbdc-4004-a49b-4e3820b1f203', '162ca2f1-07f0-4c88-94d9-44de3b939761', '9c8b6f15-2076-427e-835b-2110a20ad0d4', 'ad4a163b-f562-4173-aff1-37b936885e15', 'b149a155-8a3e-445e-b754-77c075f87c9d', 'bc314ea2-7cd5-48b5-b86e-ea6180390951', '812558b9-b3c2-4638-9432-146304a85bc3', '91bda11b-c416-472d-887b-22f700e39cbd', '82677a6c-eb15-4dd3-a5d8-a2e5c07fdd7f', '07772c38-44ad-41ca-8cba-04b07cccbf92', 'a8794d87-55bd-45ef-9281-bef4fc4302c6', '95893668-b748-4eb1-9174-fae8c319811f', 'd19b3211-190f-4b1a-a3ba-f8abfc601020', '466d5aa7-6b1a-4f29-9513-151445674eb3', '36a6d940-7b8f-422f-af18-0cf87517fa24', '3d0ddfe7-f213-406e-a4f0-62480d1be236', 'a0b5fa34-e2d3-4e3f-b9d7-7b29a4ec94be', 'd14fa877-dc20-4f12-98fb-d20c877895ff', '74fb3d22-fd98-4886-b40f-e31cf7007467', '142a00b8-b209-4c13-9265-8d8dbeaff546', '14c2d3c7-ab02-4968-bb4a-a6df560dbf5a', '2d81712d-7592-4d48-8373-a8c8e6465f9b', '74286415-0269-4b00-b1d2-9d5d9483f472', '30b321de-c44b-478b-85a0-92003c16adfe', '587c83a2-961f-4186-8616-3ed9a1fb0c22', 'c7088c65-c870-4893-9a92-169689da7486', '1eb61143-aff8-414c-bcd9-101d1f56d281', '3135780b-e1d4-4743-bd11-c5dcaa827858', '2e78bff1-361e-4716-9803-83e8073c6406', '3fc6e6b6-2677-4da1-ab01-1c5cd7d974d8', 'd0e1090b-1e6b-46c1-a719-3dd61760ad56', '764df748-58e8-47fb-a905-5cab024b4588', '73c27ea5-af89-425d-b05b-0552d72c8951', '07309f2d-15b9-4088-b274-87f5c7f6663f', '02ec451a-f08b-4561-be70-b0b1ef839990', '9531b4b4-6d16-4d0c-8a26-9831406b630a', 'a4b84d22-b857-4679-96e6-41d6133f6679', '0af0bee2-f96e-4a8c-b147-d5075a8e694c', '97adef41-54ab-45da-8dec-091bc94cdc13', 'f216b9bc-5bc9-4632-85d9-ab62997e4002', 'fbb23448-0d11-4dd0-ac3f-5c119732d54b', '3aa74cc6-fefb-448a-8d72-5b507bf5a22c', '357d84c9-9bfd-4ecc-991a-7d01db60c883', 'f46f72e2-9fac-4a11-a9dc-aaf5398988d1', 'ecc2cbb1-3c82-4c8f-8718-b3e3e2fa2fbd', 'dc017676-e57d-4fa8-9e40-1b180f9320cb', '32482e7c-fb25-44bd-8b9b-478b4e9448d6', 'f1c20bcb-299a-4889-b12a-47bac3067f7b', '10411bb8-5a5e-4f61-ba54-196b273dca8e', '70f119c5-8f3a-48e2-a7d7-1c0d1ba9899c', '5099b115-b556-48d6-b983-29975a1f352b', '40209e30-d160-439c-8471-39c2c70ff884', '2c4613b5-4a53-4235-b8a7-a16ab86a940c', '7a1f4db7-981e-4b0d-93a8-9b08a42f472d', '907cc0e7-af06-44db-b4a4-cbba3cb213fe', 'be63bea9-b62d-428b-bd49-594fdd5d83c1', 'fd6f1391-28a2-4800-a942-1b46a9180ba2', 'c32ddb06-8345-457b-83b5-3955a5938e6e', 'bc783705-7601-43e4-9078-5aee87b4ec03', '1f288e43-91b0-4b35-bfe7-60d2d6ff69da', 'f6d95fdd-872f-43ad-a6f3-82f5d5ab3336', 'fe41ace5-eac8-40cb-972b-015537fceed6', 'd1e4d336-a764-400d-8ca6-7414834fa1b2', 'a17bcce5-bceb-4e66-ab22-503aaae8a3ef', 'd5f28ee4-afcf-4000-a90d-fa3d38586da5', '00ab20db-226f-4c8c-9778-0f5689dd5417', 'a35d409f-3492-4388-a06c-83a97b766454', '885af7e6-8a64-45e3-a7d0-c1c5dc89c75e', '32ef642a-2dce-4374-8332-887b2359dad8', 'ee31569e-8cdd-4005-8498-48380f539760', '6fc29edb-4a7f-42d7-a6b8-e38d6dcb4b2d', 'e6938bfd-c485-46a8-88e7-6716c63705a8', 'd97b5ff6-d567-43a5-a4fe-c2aa5cd75a98', 'ad494df0-ed01-4ec2-badd-e23eee116bd2', 'aca29ef7-13a5-4b76-adea-1bb15ae006d4', '467161ff-e53f-4a16-baf6-8868c2ef52ff', 'fd678e2c-0ecb-41ae-9340-8c3234f77dbf', 'fdc52571-a4d3-4033-b6c0-a88fc1841db8', 'bde89d72-f464-4126-bfd5-4d148b509699', '1ea4b6fc-39ba-4668-9457-e8ffbe01bdfa', '9a9a3010-1caa-420c-801c-c7b4ba224f8b', '8d672700-710f-41a1-bcc7-f81f94e2ba25', 'bd44d7a7-37eb-4ebb-8d20-5c578cf8c60d', 'f712d2d8-f228-466c-905d-d0aefc25b723', 'ccb2e482-c304-46da-a88c-dc9a116cbcf2', 'f208238f-b069-4212-aafe-61103a7e2beb', '62a9d851-ce6a-4565-afc0-e243f23958f3', '236a6816-1133-4779-ad55-d02ff7fe3081', 'b1846089-9168-4cbe-8161-a0ab75e75f98', 'd2a20686-63d2-4027-ba7f-410b64aafe2f', '2a68e29a-3737-4f1c-b52d-abb9ece1af56', '04e572b9-3b16-4715-a3a2-932f52fa29a5', '4a9ec976-d360-4adb-bc8e-aa0599119e05', '81d2a797-eacf-4ee1-b4ab-7c1d440e7a97', 'd00be5b4-7704-45d4-a977-2645db0240f4', 'a21fa536-95b8-482c-b113-d3163627e210', 'bee6cee4-f314-4ca1-92ba-400c777de9c8', '1c11d65a-17de-40b3-86ab-dd71fde955f4', '771793e5-7c17-4ece-ab22-d13f9da42b18', 'ff09f5e6-031f-47cd-a61f-705cb11c821e', '2b6aead1-9ac3-47a3-bab4-fdacc6c3f80d', '9991700d-694b-41a4-98b0-4dd5b6232dee', '711ad65d-8edc-411f-aa49-67803096af4c', '18e3bfe6-a067-408f-bba9-d00f65a870cd', '701875e9-0bc4-4009-92f9-6d292bb6c511', '394e1c72-5e82-4433-bc8d-75b5e077488d', '4733f7f3-71b2-42e7-9c45-ff8d51497c13')
DELETE FROM "silk_request" WHERE "silk_request"."id" IN ('ff09f5e6-031f-47cd-a61f-705cb11c821e', 'fe41ace5-eac8-40cb-972b-015537fceed6', 'fdc52571-a4d3-4033-b6c0-a88fc1841db8', 'fd6f1391-28a2-4800-a942-1b46a9180ba2', 'fd678e2c-0ecb-41ae-9340-8c3234f77dbf', 'fbb23448-0d11-4dd0-ac3f-5c119732d54b', 'f712d2d8-f228-466c-905d-d0aefc25b723', 'f6d95fdd-872f-43ad-a6f3-82f5d5ab3336', 'f46f72e2-9fac-4a11-a9dc-aaf5398988d1', 'f216b9bc-5bc9-4632-85d9-ab62997e4002', 'f208238f-b069-4212-aafe-61103a7e2beb', 'f1c20bcb-299a-4889-b12a-47bac3067f7b', 'ee31569e-8cdd-4005-8498-48380f539760', 'ecc2cbb1-3c82-4c8f-8718-b3e3e2fa2fbd', 'e6938bfd-c485-46a8-88e7-6716c63705a8', 'dc017676-e57d-4fa8-9e40-1b180f9320cb', 'd97b5ff6-d567-43a5-a4fe-c2aa5cd75a98', 'd9669f6a-bbdc-4004-a49b-4e3820b1f203', 'd5f28ee4-afcf-4000-a90d-fa3d38586da5', 'd2a20686-63d2-4027-ba7f-410b64aafe2f', 'd1e4d336-a764-400d-8ca6-7414834fa1b2', 'd19b3211-190f-4b1a-a3ba-f8abfc601020', 'd14fa877-dc20-4f12-98fb-d20c877895ff', 'd0e1090b-1e6b-46c1-a719-3dd61760ad56', 'd00be5b4-7704-45d4-a977-2645db0240f4', 'ccb2e482-c304-46da-a88c-dc9a116cbcf2', 'c7088c65-c870-4893-9a92-169689da7486', 'c32ddb06-8345-457b-83b5-3955a5938e6e', 'bfce0b27-d37b-4a59-ac5e-d8bc0a4a77e2', 'bee6cee4-f314-4ca1-92ba-400c777de9c8', 'be63bea9-b62d-428b-bd49-594fdd5d83c1', 'bde89d72-f464-4126-bfd5-4d148b509699', 'bd44d7a7-37eb-4ebb-8d20-5c578cf8c60d', 'bc783705-7601-43e4-9078-5aee87b4ec03', 'bc314ea2-7cd5-48b5-b86e-ea6180390951', 'b1846089-9168-4cbe-8161-a0ab75e75f98', 'b149a155-8a3e-445e-b754-77c075f87c9d', 'ad4a163b-f562-4173-aff1-37b936885e15', 'ad494df0-ed01-4ec2-badd-e23eee116bd2', 'aca29ef7-13a5-4b76-adea-1bb15ae006d4', 'a8794d87-55bd-45ef-9281-bef4fc4302c6', 'a4b84d22-b857-4679-96e6-41d6133f6679', 'a35d409f-3492-4388-a06c-83a97b766454', 'a21fa536-95b8-482c-b113-d3163627e210', 'a17bcce5-bceb-4e66-ab22-503aaae8a3ef', 'a0b5fa34-e2d3-4e3f-b9d7-7b29a4ec94be', '9c8b6f15-2076-427e-835b-2110a20ad0d4', '9a9a3010-1caa-420c-801c-c7b4ba224f8b', '9991700d-694b-41a4-98b0-4dd5b6232dee', '97adef41-54ab-45da-8dec-091bc94cdc13', '95893668-b748-4eb1-9174-fae8c319811f', '9531b4b4-6d16-4d0c-8a26-9831406b630a', '91bda11b-c416-472d-887b-22f700e39cbd', '907cc0e7-af06-44db-b4a4-cbba3cb213fe', '8d672700-710f-41a1-bcc7-f81f94e2ba25', '885af7e6-8a64-45e3-a7d0-c1c5dc89c75e', '82677a6c-eb15-4dd3-a5d8-a2e5c07fdd7f', '81d2a797-eacf-4ee1-b4ab-7c1d440e7a97', '812558b9-b3c2-4638-9432-146304a85bc3', '7a1f4db7-981e-4b0d-93a8-9b08a42f472d', '771793e5-7c17-4ece-ab22-d13f9da42b18', '764df748-58e8-47fb-a905-5cab024b4588', '74fb3d22-fd98-4886-b40f-e31cf7007467', '74286415-0269-4b00-b1d2-9d5d9483f472', '73c27ea5-af89-425d-b05b-0552d72c8951', '711ad65d-8edc-411f-aa49-67803096af4c', '70f119c5-8f3a-48e2-a7d7-1c0d1ba9899c', '701875e9-0bc4-4009-92f9-6d292bb6c511', '6fc29edb-4a7f-42d7-a6b8-e38d6dcb4b2d', '62a9d851-ce6a-4565-afc0-e243f23958f3', '587c83a2-961f-4186-8616-3ed9a1fb0c22', '5099b115-b556-48d6-b983-29975a1f352b', '4a9ec976-d360-4adb-bc8e-aa0599119e05', '4733f7f3-71b2-42e7-9c45-ff8d51497c13', '467161ff-e53f-4a16-baf6-8868c2ef52ff', '466d5aa7-6b1a-4f29-9513-151445674eb3', '40209e30-d160-439c-8471-39c2c70ff884', '3fc6e6b6-2677-4da1-ab01-1c5cd7d974d8', '3d0ddfe7-f213-406e-a4f0-62480d1be236', '3aa74cc6-fefb-448a-8d72-5b507bf5a22c', '394e1c72-5e82-4433-bc8d-75b5e077488d', '36a6d940-7b8f-422f-af18-0cf87517fa24', '357d84c9-9bfd-4ecc-991a-7d01db60c883', '32ef642a-2dce-4374-8332-887b2359dad8', '32482e7c-fb25-44bd-8b9b-478b4e9448d6', '3135780b-e1d4-4743-bd11-c5dcaa827858', '30b321de-c44b-478b-85a0-92003c16adfe', '2e78bff1-361e-4716-9803-83e8073c6406', '2d81712d-7592-4d48-8373-a8c8e6465f9b', '2c4613b5-4a53-4235-b8a7-a16ab86a940c', '2b6aead1-9ac3-47a3-bab4-fdacc6c3f80d', '2a68e29a-3737-4f1c-b52d-abb9ece1af56', '236a6816-1133-4779-ad55-d02ff7fe3081', '1f288e43-91b0-4b35-bfe7-60d2d6ff69da', '1eb61143-aff8-414c-bcd9-101d1f56d281', '1ea4b6fc-39ba-4668-9457-e8ffbe01bdfa', '1c11d65a-17de-40b3-86ab-dd71fde955f4', '18e3bfe6-a067-408f-bba9-d00f65a870cd', '162ca2f1-07f0-4c88-94d9-44de3b939761', '14c2d3c7-ab02-4968-bb4a-a6df560dbf5a')
DELETE FROM "silk_request" WHERE "silk_request"."id" IN ('142a00b8-b209-4c13-9265-8d8dbeaff546', '10411bb8-5a5e-4f61-ba54-196b273dca8e', '0af0bee2-f96e-4a8c-b147-d5075a8e694c', '07772c38-44ad-41ca-8cba-04b07cccbf92', '07309f2d-15b9-4088-b274-87f5c7f6663f', '04e572b9-3b16-4715-a3a2-932f52fa29a5', '02ec451a-f08b-4561-be70-b0b1ef839990', '00ab20db-226f-4c8c-9778-0f5689dd5417')
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (123249, 123248, 123247, 123246, 123245, 123244, 123243, 123242, 123241, 123240, 123239, 123238, 123237, 123236, 123235, 123234, 123233, 123232, 123231, 123230, 123229, 123228, 123227, 123226, 123225, 123224, 123223, 123222, 123221, 123220, 123219, 123218, 123217, 123216, 123215, 123214, 123213, 123212, 123211, 123210, 123209, 123208, 123207, 123206, 123205, 123204, 123203, 123202, 123201, 123200, 123199, 123198, 123197, 123196, 123195, 123194, 123193, 123192, 123191, 123190, 123189, 123188, 123187, 123186, 123185, 123184, 123183, 123182, 123181, 123180, 123179, 123178, 123177, 123176, 123175, 123174, 123173, 123172, 123171, 123170, 123169, 123168, 123167, 123166, 123165, 123164, 123163, 123162, 123161, 123160, 123159, 123158, 123157, 123156, 123155, 123154, 123153, 123152, 123151, 123150)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (123149, 123148, 123147, 123146, 123145, 123144, 123143, 123142, 123141, 123140, 123139, 123138, 123137, 123136, 123135, 123134, 123133, 123132, 123131, 123130, 123129, 123128, 123127, 123126, 123125, 123124, 123123, 123122, 123121, 123120, 123119, 123118, 123117, 123116, 123115, 123114, 123113, 123112, 123111, 123110, 123109, 123108, 123107, 123106, 123105, 123104, 123103, 123102, 123101, 123100, 123099, 123098, 123097, 123096, 123095, 123094, 123093, 123092, 123091, 123090, 123089, 123088, 123087, 123086, 123085, 123084, 123083, 123082, 123081, 123080, 123079, 123078, 123077, 123076, 123075, 123074, 123073, 123072, 123071, 123070, 123069, 123068, 123067, 123066, 123065, 123064, 123063, 123062, 123061, 123060, 123059, 123058, 123057, 123056, 123055, 123054, 123053, 123052, 123051, 123050)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (123049, 123048, 123047, 123046, 123045, 123044, 123043, 123042, 123041, 123040, 123039, 123038, 123037, 123036, 123035, 123034, 123033, 123032, 123031, 123030, 123029, 123028, 123027, 123026, 123025, 123024, 123023, 123022, 123021, 123020, 123019, 123018, 123017, 123016, 123015, 123014, 123013, 123012, 123011, 123010, 123009, 123008, 123007, 123006, 123005, 123004, 123003, 123002, 123001, 123000, 122999, 122998, 122997, 122996, 122995, 122994, 122993, 122992, 122991, 122990, 122989, 122988, 122987, 122986, 122985, 122984, 122983, 122982, 122981, 122980, 122979, 122978, 122977, 122976, 122975, 122974, 122973, 122972, 122971, 122970, 122969, 122968, 122967, 122966, 122965, 122964, 122963, 122962, 122961, 122960, 122959, 122958, 122957, 122956, 122955, 122954, 122953, 122952, 122951, 122950)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (122949, 122948, 122947, 122946, 122945, 122944, 122943, 122942, 122941, 122940, 122939, 122938, 122937, 122936, 122935, 122934, 122933, 122932, 122931, 122930, 122929, 122928, 122927, 122926, 122925, 122924, 122923, 122922, 122921, 122920, 122919, 122918, 122917, 122916, 122915, 122914, 122913, 122912, 122911, 122910, 122909, 122908, 122907, 122906, 122905, 122904, 122903, 122902, 122901, 122900, 122899, 122898, 122897, 122896, 122895, 122894, 122893, 122892, 122891, 122890, 122889, 122888, 122887, 122886, 122885, 122884, 122883, 122882, 122881, 122880, 122879, 122878, 122877, 122876, 122875, 122874, 122873, 122872, 122871, 122870, 122869, 122868, 122867, 122866, 122865, 122864, 122863, 122862, 122861, 122860, 122859, 122858, 122857, 122856, 122855, 122854, 122853, 122852, 122851, 122850)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (122849, 122848, 122847, 122846, 122845, 122844, 122843, 122842, 122841, 122840, 122839, 122838, 122837, 122836, 122835, 122834, 122833, 122832, 122831, 122830, 122829, 122828, 122827, 122826, 122825, 122824, 122823, 122822, 122821, 122820, 122819, 122818, 122817, 122816, 122815, 122814, 122813, 122812, 122811, 122810, 122809, 122808, 122807, 122806, 122805, 122804, 122803, 122802, 122801, 122800, 122799, 122798, 122797, 122796, 122795, 122794, 122793, 122792, 122791, 122790, 122789, 122788, 122787, 122786, 122785, 122784, 122783, 122782, 122781, 122780, 122779, 122778, 122777, 122776, 122775, 122774, 122773, 122772, 122771, 122770, 122769, 122768, 122767, 122766, 122765, 122764, 122763, 122762, 122761, 122760, 122759, 122758, 122757, 122756, 122755, 122754, 122753, 122752, 122751, 122750)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (122749, 122748, 122747, 122746, 122745, 122744, 122743, 122742, 122741, 122740, 122739, 122738, 122737, 122736, 122735, 122734, 122733, 122732, 122731, 122730, 122729, 122728, 122727, 122726, 122725, 122724, 122723, 122722, 122721, 122720, 122719, 122718, 122717, 122716, 122715, 122714, 122713, 122712, 122711, 122710, 122709, 122708, 122707, 122706, 122705, 122704, 122703, 122702, 122701, 122700, 122699, 122698, 122697, 122696, 122695, 122694, 122693, 122692, 122691, 122690, 122689, 122688, 122687, 122686, 122685, 122684, 122683, 122682, 122681, 122680, 122679, 122678, 122677, 122676, 122675, 122674, 122673, 122672, 122671, 122670, 122669, 122668, 122667, 122666, 122665, 122664, 122663, 122662, 122661, 122660, 122659, 122658, 122657, 122656, 122655, 122654, 122653, 122652, 122651, 122650)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (122649, 122648, 122647, 122646, 122645, 122644, 122643, 122642, 122641, 122640, 122639, 122638, 122637, 122636, 122635, 122634, 122633, 122632, 122631, 122630, 122629, 122628, 122627, 122626, 122625, 122624, 122623, 122622, 122621, 122620, 122619, 122618, 122617, 122616, 122615, 122614, 122613, 122612, 122611, 122610, 122609, 122608, 122607, 122606, 122605, 122604, 122603, 122602, 122601, 122600, 122599, 122598, 122597, 122596, 122595, 122594, 122593, 122592, 122591, 122590, 122589, 122588, 122587, 122586, 122585, 122584, 122583, 122582, 122581, 122580, 122579, 122578, 122577, 122576, 122575, 122574, 122573, 122572, 122571, 122570, 122569, 122568, 122567, 122566, 122565, 122564, 122563, 122562, 122561, 122560, 122559, 122558, 122557, 122556, 122555, 122554, 122553, 122552, 122551, 122550)
DELETE FROM "silk_sqlquery" WHERE "silk_sqlquery"."id" IN (122549, 122548, 122547, 122546, 122545, 122544, 122543, 122542, 122541, 122540, 122539, 122538, 122537, 122536, 122535, 122534, 122533, 122532, 122531, 122530, 122529, 122528, 122527, 122526, 122525, 122524, 122523, 122522, 122521, 122520, 122519, 122518, 122517, 122516, 122515, 122514, 122513, 122512, 122511, 122510, 122509, 122508, 122507, 122506, 122505, 122504, 122503, 122502, 122501, 122500, 122499, 122498, 122497, 122496, 122495, 122494)
COMMIT

@sergei-iurchenko
Copy link

It is possible to use
Request.objects.all()._raw_delete(Request.objects.db)
to execute DELETE query without loading all rows to memory.
If some db constrains are violated db would return error.

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