-
Notifications
You must be signed in to change notification settings - Fork 67
Долгий одиночный insert (online_analyze) #113
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
Comments
попробовал убрать родителя из анализа.... сначала смотрим план: explain(COSTS, BUFFERS, TIMING, ANALYZE, VERBOSE)
INSERT INTO base.fact_events (rgu_service_id, rgu_authority_id, created_at, updated_at)
VALUES (165708, 91643, '2017-08-14 08:52:23.798822', '2017-08-14 08:52:23.798822')
RETURNING id;
QUERY PLAN
Insert on base.fact_events (cost=0.00..0.01 rows=1 width=148) (actual time=0.354..0.355 rows=1 loops=1)
Output: id
Buffers: shared hit=22 dirtied=1
-> Custom Scan (PartitionFilter) (cost=0.00..0.01 rows=1 width=148) (actual time=0.050..0.051 rows=1 loops=1)
Output: (nextval('base.fact_events_id_seq'::regclass)), (165708), (91643), (NULL::integer), (NULL::integer), ('2017-08-14 08:52:23.798822'::timestamp without time zone), ('2017-08-14 08:52:23.798822'::timestamp without time zone), (NULL::timestamp without time zone), (NULL::date), (NULL::character varying), (NULL::character varying), (NULL::character varying)
Buffers: shared hit=2
-> Result (cost=0.00..0.01 rows=1 width=148) (actual time=0.021..0.021 rows=1 loops=1)
Output: nextval('base.fact_events_id_seq'::regclass), 165708, 91643, NULL::integer, NULL::integer, '2017-08-14 08:52:23.798822'::timestamp without time zone, '2017-08-14 08:52:23.798822'::timestamp without time zone, NULL::timestamp without time zone, NULL::date, NULL::character varying, NULL::character varying, NULL::character varying
Buffers: shared hit=2
Planning time: 0.054 ms
Trigger RI_ConstraintTrigger_c_193188 for constraint fact_events_68_rgu_service_id_fkey on fact_events_68: time=0.179 calls=1
Trigger RI_ConstraintTrigger_c_193193 for constraint fact_events_68_rgu_authority_id_fkey on fact_events_68: time=0.085 calls=1
Execution time: 829.602 ms теперь выполняем код в транзакции begin;
INSERT INTO base.fact_events (rgu_service_id, rgu_authority_id, created_at, updated_at)
VALUES (165708, 91643, '2017-08-14 08:52:23.798822', '2017-08-14 08:52:23.798822')
RETURNING id;
rollback; результат: INFO: analyzing "base.fact_events"
INFO: "fact_events": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
INFO: analyzing "base.fact_events" inheritance tree
INFO: "fact_events_11": scanned 1 of 2 pages, containing 40 live rows and 0 dead rows; 1 rows in sample, 109 estimated total rows
INFO: "fact_events_12": scanned 1 of 2 pages, containing 74 live rows and 0 dead rows; 1 rows in sample, 160 estimated total rows
INFO: "fact_events_16": scanned 579 of 1161 pages, containing 45156 live rows and 0 dead rows; 579 rows in sample, 90594 estimated total rows
INFO: "fact_events_17": scanned 998 of 2002 pages, containing 77874 live rows and 0 dead rows; 998 rows in sample, 156202 estimated total rows
INFO: "fact_events_18": scanned 458 of 918 pages, containing 35859 live rows and 0 dead rows; 458 rows in sample, 71878 estimated total rows
INFO: "fact_events_19": scanned 786 of 1576 pages, containing 61454 live rows and 0 dead rows; 786 rows in sample, 123197 estimated total rows
INFO: "fact_events_20": scanned 719 of 1442 pages, containing 56117 live rows and 0 dead rows; 719 rows in sample, 112542 estimated total rows
INFO: "fact_events_21": scanned 865 of 1735 pages, containing 67565 live rows and 0 dead rows; 865 rows in sample, 135523 estimated total rows
INFO: "fact_events_22": scanned 815 of 1636 pages, containing 63530 live rows and 0 dead rows; 815 rows in sample, 127552 estimated total rows
INFO: "fact_events_23": scanned 824 of 1654 pages, containing 64640 live rows and 0 dead rows; 824 rows in sample, 129751 estimated total rows
INFO: "fact_events_24": scanned 459 of 921 pages, containing 35832 live rows and 0 dead rows; 459 rows in sample, 71917 estimated total rows
INFO: "fact_events_25": scanned 487 of 978 pages, containing 37996 live rows and 0 dead rows; 487 rows in sample, 76325 estimated total rows
INFO: "fact_events_26": scanned 750 of 1505 pages, containing 58597 live rows and 0 dead rows; 750 rows in sample, 117592 estimated total rows
INFO: "fact_events_27": scanned 590 of 1183 pages, containing 46080 live rows and 0 dead rows; 590 rows in sample, 92423 estimated total rows
INFO: "fact_events_28": scanned 555 of 1113 pages, containing 43458 live rows and 0 dead rows; 555 rows in sample, 87126 estimated total rows
INFO: "fact_events_29": scanned 3000 of 6019 pages, containing 285002 live rows and 0 dead rows; 3000 rows in sample, 571504 estimated total rows
INFO: "fact_events_30": scanned 1980 of 3973 pages, containing 187504 live rows and 0 dead rows; 1980 rows in sample, 376254 estimated total rows
INFO: "fact_events_31": scanned 2399 of 4813 pages, containing 226731 live rows and 0 dead rows; 2399 rows in sample, 455076 estimated total rows
INFO: "fact_events_32": scanned 2586 of 5187 pages, containing 239826 live rows and 0 dead rows; 2586 rows in sample, 480805 estimated total rows
INFO: "fact_events_33": scanned 3179 of 6377 pages, containing 299072 live rows and 0 dead rows; 3179 rows in sample, 600298 estimated total rows
INFO: "fact_events_34": scanned 2642 of 5301 pages, containing 254689 live rows and 0 dead rows; 2642 rows in sample, 511168 estimated total rows
INFO: "fact_events_35": scanned 3216 of 6452 pages, containing 310780 live rows and 0 dead rows; 3216 rows in sample, 623665 estimated total rows
INFO: "fact_events_36": scanned 4207 of 8440 pages, containing 400185 live rows and 0 dead rows; 4207 rows in sample, 802499 estimated total rows
INFO: "fact_events_37": scanned 1908 of 3827 pages, containing 183396 live rows and 0 dead rows; 1908 rows in sample, 367819 estimated total rows
INFO: "fact_events_38": scanned 2138 of 4290 pages, containing 205361 live rows and 0 dead rows; 2138 rows in sample, 412113 estimated total rows
INFO: "fact_events_39": scanned 2786 of 5589 pages, containing 265858 live rows and 0 dead rows; 2786 rows in sample, 533728 estimated total rows
INFO: "fact_events_40": scanned 2786 of 5589 pages, containing 264817 live rows and 0 dead rows; 2786 rows in sample, 531234 estimated total rows
INFO: "fact_events_41": scanned 2769 of 5555 pages, containing 262277 live rows and 0 dead rows; 2769 rows in sample, 526120 estimated total rows
INFO: "fact_events_42": scanned 2615 of 5247 pages, containing 248475 live rows and 0 dead rows; 2615 rows in sample, 498431 estimated total rows
INFO: "fact_events_43": scanned 1183 of 2374 pages, containing 113512 live rows and 0 dead rows; 1183 rows in sample, 227686 estimated total rows
INFO: "fact_events_44": scanned 434 of 871 pages, containing 42082 live rows and 0 dead rows; 434 rows in sample, 84414 estimated total rows
INFO: "fact_events_45": scanned 539 of 1081 pages, containing 51935 live rows and 0 dead rows; 539 rows in sample, 104161 estimated total rows
INFO: "fact_events_46": scanned 1108 of 2223 pages, containing 102478 live rows and 0 dead rows; 1108 rows in sample, 205572 estimated total rows
INFO: "fact_events_47": scanned 1213 of 2434 pages, containing 113504 live rows and 0 dead rows; 1213 rows in sample, 227750 estimated total rows
INFO: "fact_events_48": scanned 1297 of 2603 pages, containing 121730 live rows and 0 dead rows; 1297 rows in sample, 244380 estimated total rows
INFO: "fact_events_49": scanned 1233 of 2474 pages, containing 113994 live rows and 0 dead rows; 1233 rows in sample, 228835 estimated total rows
INFO: "fact_events_50": scanned 1609 of 3228 pages, containing 155489 live rows and 0 dead rows; 1609 rows in sample, 311928 estimated total rows
INFO: "fact_events_51": scanned 3711 of 7445 pages, containing 359519 live rows and 0 dead rows; 3711 rows in sample, 721315 estimated total rows
INFO: "fact_events_52": scanned 5686 of 11407 pages, containing 551058 live rows and 0 dead rows; 5686 rows in sample, 1105521 estimated total rows
INFO: "fact_events_53": scanned 3921 of 7866 pages, containing 379544 live rows and 0 dead rows; 3921 rows in sample, 761432 estimated total rows
INFO: "fact_events_54": scanned 4266 of 8559 pages, containing 413129 live rows and 0 dead rows; 4266 rows in sample, 828944 estimated total rows
INFO: "fact_events_55": scanned 4237 of 8500 pages, containing 410146 live rows and 0 dead rows; 4237 rows in sample, 822798 estimated total rows
INFO: "fact_events_56": scanned 4667 of 9362 pages, containing 451866 live rows and 0 dead rows; 4667 rows in sample, 906479 estimated total rows
INFO: "fact_events_57": scanned 3906 of 7836 pages, containing 378137 live rows and 0 dead rows; 3906 rows in sample, 758609 estimated total rows
INFO: "fact_events_58": scanned 4176 of 8377 pages, containing 404407 live rows and 1 dead rows; 4176 rows in sample, 811219 estimated total rows
INFO: "fact_events_59": scanned 4077 of 8180 pages, containing 394743 live rows and 0 dead rows; 4077 rows in sample, 791992 estimated total rows
INFO: "fact_events_60": scanned 5207 of 10447 pages, containing 504111 live rows and 0 dead rows; 5207 rows in sample, 1011439 estimated total rows
INFO: "fact_events_61": scanned 3090 of 6200 pages, containing 299143 live rows and 0 dead rows; 3090 rows in sample, 600206 estimated total rows
INFO: "fact_events_62": scanned 2929 of 5876 pages, containing 283073 live rows and 0 dead rows; 2929 rows in sample, 567890 estimated total rows
INFO: "fact_events_63": scanned 3385 of 6790 pages, containing 327427 live rows and 0 dead rows; 3385 rows in sample, 656692 estimated total rows
INFO: "fact_events_64": scanned 3478 of 6977 pages, containing 336319 live rows and 0 dead rows; 3478 rows in sample, 674665 estimated total rows
INFO: "fact_events_65": scanned 2176 of 4366 pages, containing 210492 live rows and 0 dead rows; 2176 rows in sample, 422328 estimated total rows
INFO: "fact_events_66": scanned 2789 of 5595 pages, containing 269718 live rows and 0 dead rows; 2789 rows in sample, 541094 estimated total rows
INFO: "fact_events_67": scanned 2298 of 4610 pages, containing 222103 live rows and 0 dead rows; 2298 rows in sample, 445551 estimated total rows
INFO: "fact_events_68": scanned 282 of 566 pages, containing 27271 live rows and 1 dead rows; 282 rows in sample, 54688 estimated total rows
INFO: analyze "fact_events" took 0.81 seconds
Total query runtime: 843 msec
1 row retrieved. конечно быстрее, НО причём здесь сканирование всех секций? |
Это хороший вопрос! Я думаю, его нужно задавать автору расширения online analyze :) Я посмотрю, с чем это может быть связано. |
Вот оно, что...
я попробую его сейчас отключить... |
я сделал следующее alter system set online_analyze.enable = off; и после этого всё залетало |
Отлично, но я все же попробую разобраться, может сделаю патч для online_analyze. |
Да, это было бы очень хорошо. |
Можно указать партицированную таблицу в
К сожалению, нет, я воспроизводил с online_analyze + plantuner. |
Спасибо, будем ждать обновления. Пока отключил через exclude_tables |
Uh oh!
There was an error while loading. Please reload this page.
Работаю на следующих версиях:
использую RANGE секционирование 1 месяц. Выполняю такой код:
на таблице base.fact_events сейчас 68 секций
структура таблицы
индекс по полю created_at есть на таблицах наследования
данные в конфиге
до этого пакетно в таблицу вставилось
и потом конкуретно выполнено партиционирование.
после этого был выполнен VACUUM FULL FREEZE ANALYZE base.fact_events;
главная таблицы после этого имеет размер 48кб и 0 строк. Все данные распределены по секциям.
выполняю вставку 1 строки
сначала смотрим план:
теперь выполняем код в транзакции
результат:
1.5 секунды + идут сканирования всех секций... что я делаю не так?
The text was updated successfully, but these errors were encountered: