diff --git a/db/sql/postgres/docs/presentations.txt b/db/sql/postgres/docs/presentations.txt index 908b8c08f..7bf24ea64 100644 --- a/db/sql/postgres/docs/presentations.txt +++ b/db/sql/postgres/docs/presentations.txt @@ -1,6 +1,8 @@ https://speakerdeck.com/pgpro 2024 +Tenzor - Borovikov - Useful SQL Constructions in PG 0:00 of 58:01 + https://www.youtube.com/watch?v=nf3b2QmG_jA YandexForBackend - Valkov - PG for Java Developer 25:00 of 44:21 https://www.youtube.com/watch?v=QzIUHvDnEaI ! 13:00 - Hikary Cfg (timeouts) diff --git a/db/sql/postgres/feature/index/presentations.txt b/db/sql/postgres/feature/index/presentations.txt deleted file mode 100644 index 682540b70..000000000 --- a/db/sql/postgres/feature/index/presentations.txt +++ /dev/null @@ -1,15 +0,0 @@ -2024 -AzatYakupov - BTree Index in PG 0:00 of 1:09:10 - https://www.youtube.com/watch?v=hMoBH7drftk -JPoint - Salnikov - PostgreSQL Indices ru 0:00 of 2:00:44 - https://www.youtube.com/watch?v=ju9F8OvnL4E - https://squidex.jugru.team/api/assets/srm/5a15546d-af53-46d4-be84-63367a5aaaf3/jpoint2022.andrei-.salsnikov.pdf -2023 -JPoint - Sitnikov - B-Tree indices using Boot, PostgreSQL, JPA 18:00 of 45:07 - https://www.youtube.com/watch?v=y-Wtyvme4gE - ! using indices improves search-perf, but degrades ins/upd perf - ! indices have types - ! 21:30 explain (analyze, costs off, buffers) -- buffers is aprox about num of disk ops -2017 -BartunovKorotkov - All truth about Indices 0:00 of 46:35 - https://www.youtube.com/watch?v=aaecM4wKdhY diff --git a/db/sql/postgres/feature/internals/articles.txt b/db/sql/postgres/feature/internals/articles.txt deleted file mode 100644 index 9c3d63166..000000000 --- a/db/sql/postgres/feature/internals/articles.txt +++ /dev/null @@ -1,6 +0,0 @@ -2024 -https://habr.com/ru/articles/830924/ -https://habr.com/ru/articles/815323/ -https://habr.com/ru/articles/813781/ -2023 -https://habr.com/ru/post/696274/ diff --git a/db/sql/postgres/feature/internals/docs/articles.txt b/db/sql/postgres/feature/internals/docs/articles.txt new file mode 100644 index 000000000..9173d5f88 --- /dev/null +++ b/db/sql/postgres/feature/internals/docs/articles.txt @@ -0,0 +1,9 @@ +2024 +pg16 - p3 - pages/buffers and versions of rows p3 + https://habr.com/ru/articles/830924/ +pg16 - p2 - transaction isolation + https://habr.com/ru/articles/815323/ +pg16 - p1 - data organisation + https://habr.com/ru/articles/813781/ +2023 +https://habr.com/ru/post/696274/ diff --git a/db/sql/postgres/feature/internals/docs/blogs.txt b/db/sql/postgres/feature/internals/docs/blogs.txt new file mode 100644 index 000000000..edec3abe9 --- /dev/null +++ b/db/sql/postgres/feature/internals/docs/blogs.txt @@ -0,0 +1 @@ +https://stormatics.tech/our-blogs diff --git a/db/sql/postgres/feature/internals/docs/books.txt b/db/sql/postgres/feature/internals/docs/books.txt new file mode 100644 index 000000000..f696a3ae0 --- /dev/null +++ b/db/sql/postgres/feature/internals/docs/books.txt @@ -0,0 +1,3 @@ +2024 +Lisovskiy - Statistics ru + https://edu.postgrespro.ru/monitoring.pdf diff --git a/db/sql/postgres/feature/internals/presentations.txt b/db/sql/postgres/feature/internals/docs/presentations.txt similarity index 100% rename from db/sql/postgres/feature/internals/presentations.txt rename to db/sql/postgres/feature/internals/docs/presentations.txt diff --git a/db/sql/postgres/feature/performance/articles.txt b/db/sql/postgres/feature/performance/docs/articles.txt similarity index 100% rename from db/sql/postgres/feature/performance/articles.txt rename to db/sql/postgres/feature/performance/docs/articles.txt diff --git a/db/sql/postgres/feature/performance/docs/courses.txt b/db/sql/postgres/feature/performance/docs/courses.txt new file mode 100644 index 000000000..c567d6e90 --- /dev/null +++ b/db/sql/postgres/feature/performance/docs/courses.txt @@ -0,0 +1,4 @@ +2023 +PostgresProfessional - RogovLuzanovTolmachyov - QPT13 - Query Optimization of p12 + https://postgrespro.ru/education/courses/QPT + https://www.youtube.com/playlist?list=PLaFqU3KCWw6JW80WBHPOe-SMJD2NOjmge diff --git a/db/sql/postgres/feature/performance/docs/presentations.txt b/db/sql/postgres/feature/performance/docs/presentations.txt new file mode 100644 index 000000000..db92e928c --- /dev/null +++ b/db/sql/postgres/feature/performance/docs/presentations.txt @@ -0,0 +1,27 @@ +2024 +Digitalize - PG Optimization Basics 1:46:00 of 2:07:51 + https://www.youtube.com/watch?v=gA3A_epB3So + ! 13:00 - from index pages go into buffer-cache in RAM + ! 37:00 - select ... from employee e join contacts ec using(employee_id) -- on e.employee_id = ec.employee_id + ! 39:00 - data access methods: seq-scan, idx-scan(with going into table), index-only-scan(without going into table), bitmap-heap-scan + ! 45:00 - Seq Scan on employee (cost=0.00..173528.84 rows ...) + ! 0.00 - cost of first raw obtaining, 173528.84 - cost of all rows obtaining + ! 47:00 select relpages, current_setting('seq_page_cost'), relpages*current_setting('seq_page_cost')::int as total + ! from pg_class where relname='employee'; + ! relpages: 73 530 + ! current_setting: 1 + ! total: 73 530 + ! 53:00 selectivity (0.0 .. 1.0) - percentage/proportion of chosen rows + ! idx is effectively used only on low-selectivity, otherwise - seq scan + ! 1:08:00 - vacuum analyze - for updating statistics + ! 1:17:00 - create extension pg_stat_statements; alter system set shared_preload_libraries = 'pg_stat_statements'; + ! 1:18:00 - other perf-related settings !!! + ! recommendation - https://www.youtube.com/playlist?list=PLaFqU3KCWw6JW80WBHPOe-SMJD2NOjmge +JPoint - Zhilin - PG Can Make a Pain 0:00 of 45:49 + https://www.youtube.com/watch?v=pTWfjyeQ5Ks + https://jokerconf.com/talks/0bd645ad3a0f48c292547db572a1c7eb +WorkSolutions - Kostenko - Postgres World Optimization Misteries ru 0:00 of 32:50 + https://www.youtube.com/watch?v=MeTDmLyYD9k +2023 +Tenzor - Backend School of p9 + https://www.youtube.com/playlist?list=PLt0vzWoDuwcTdFnp-QWtx2yEvKMDlPw7l diff --git a/db/sql/postgres/feature/performance/tips.txt b/db/sql/postgres/feature/performance/docs/tips.txt similarity index 99% rename from db/sql/postgres/feature/performance/tips.txt rename to db/sql/postgres/feature/performance/docs/tips.txt index d7c5893da..9b5f0d742 100644 --- a/db/sql/postgres/feature/performance/tips.txt +++ b/db/sql/postgres/feature/performance/docs/tips.txt @@ -78,7 +78,9 @@ SELECT * FROM table WHERE email ILIKE ‘example@yandex.ru‘; ILIKE является расширением оператора LIKE и не описан в стандарте SQL, это фишка PostgreSQL. ILIKE позволяет нам делать независимый от регистра поиск по заданному шаблону с учетом языковой среды, в которой установлена PostgreSQL. B-tree индекс не поддерживает данный оператор, так что в таком запросе индекс на поле email не будет использован. -Здесь мы рассмотрели варианты почему PostgreSQL НЕ МОЖЕТ использовать индекс, завтра мы с вами рассмотрим варианты, при которых PostgreSQL НЕ ХОЧЕТ использовать индекс, а предпочитать последовательное сканирование, или еще какие-то другие методы сканирования данных.************************************************************************************ +Здесь мы рассмотрели варианты почему PostgreSQL НЕ МОЖЕТ использовать индекс, завтра мы с вами рассмотрим варианты, при которых PostgreSQL НЕ ХОЧЕТ использовать индекс, а предпочитать последовательное сканирование, или еще какие-то другие методы сканирования данных. + +************************************************************************************ Захотели мы ускорить запрос, создали индекс по нужной колонке таблицы и успокоились. А PostgreSQL не использует, созданный нами индекс и продолжает делать последовательное сканирование по таблице, например. В этой серии постов попытаемся разобраться почему так может происходить. В расследовании проблем с индексами лучший наш друг, это команда EXPLAIN. Она, конечно, не покажет нам точную причину неиспользования индекса PostgreSQL, но по крайней мере задаст направление, в котором нам следует производить расследование. diff --git a/db/sql/postgres/feature/performance/explain/analyze.txt b/db/sql/postgres/feature/performance/explain/analyze.txt new file mode 100644 index 000000000..ab443e8b9 --- /dev/null +++ b/db/sql/postgres/feature/performance/explain/analyze.txt @@ -0,0 +1 @@ +https://www.postgresql.org/docs/current/sql-analyze.html diff --git a/db/sql/postgres/feature/performance/explain/presentations.txt b/db/sql/postgres/feature/performance/explain/presentations.txt new file mode 100644 index 000000000..da08b3598 --- /dev/null +++ b/db/sql/postgres/feature/performance/explain/presentations.txt @@ -0,0 +1,5 @@ +2023 +Tenzor - Backend School p4 - Query Analysis p2 0:00 of 1:40:59 + https://www.youtube.com/watch?v=Rg7AAEso3z0 +Tenzor - Backend School p4 - Query Analysis p1 0:00 of 1:24:11 + https://www.youtube.com/watch?v=4g2CJv0jRk0 diff --git a/db/sql/postgres/feature/index/articles.txt b/db/sql/postgres/feature/performance/index/articles.txt similarity index 100% rename from db/sql/postgres/feature/index/articles.txt rename to db/sql/postgres/feature/performance/index/articles.txt diff --git a/db/sql/postgres/feature/index/auto.txt b/db/sql/postgres/feature/performance/index/auto.txt similarity index 100% rename from db/sql/postgres/feature/index/auto.txt rename to db/sql/postgres/feature/performance/index/auto.txt diff --git a/db/sql/postgres/feature/index/gist.txt b/db/sql/postgres/feature/performance/index/gist.txt similarity index 100% rename from db/sql/postgres/feature/index/gist.txt rename to db/sql/postgres/feature/performance/index/gist.txt diff --git a/db/sql/postgres/feature/index/index.txt b/db/sql/postgres/feature/performance/index/index.txt similarity index 100% rename from db/sql/postgres/feature/index/index.txt rename to db/sql/postgres/feature/performance/index/index.txt diff --git a/db/sql/postgres/feature/index/intersected.txt b/db/sql/postgres/feature/performance/index/intersected.txt similarity index 100% rename from db/sql/postgres/feature/index/intersected.txt rename to db/sql/postgres/feature/performance/index/intersected.txt diff --git a/db/sql/postgres/feature/index/level.txt b/db/sql/postgres/feature/performance/index/level.txt similarity index 100% rename from db/sql/postgres/feature/index/level.txt rename to db/sql/postgres/feature/performance/index/level.txt diff --git a/db/sql/postgres/feature/index/partial.txt b/db/sql/postgres/feature/performance/index/partial.txt similarity index 100% rename from db/sql/postgres/feature/index/partial.txt rename to db/sql/postgres/feature/performance/index/partial.txt diff --git a/db/sql/postgres/feature/performance/index/presentations.txt b/db/sql/postgres/feature/performance/index/presentations.txt new file mode 100644 index 000000000..670867392 --- /dev/null +++ b/db/sql/postgres/feature/performance/index/presentations.txt @@ -0,0 +1,28 @@ +2024 +AzatYakupov - BTree Index in PG 0:00 of 1:09:10 + https://www.youtube.com/watch?v=hMoBH7drftk +JPoint - Salnikov - PostgreSQL Indices ru 0:00 of 2:00:44 + https://www.youtube.com/watch?v=ju9F8OvnL4E + https://squidex.jugru.team/api/assets/srm/5a15546d-af53-46d4-be84-63367a5aaaf3/jpoint2022.andrei-.salsnikov.pdf +2023 +JPoint - Sitnikov - B-Tree indices using Boot, PostgreSQL, JPA 18:00 of 45:07 + https://www.youtube.com/watch?v=y-Wtyvme4gE + ! using indices improves search-perf, but degrades ins/upd perf + ! indices have types + ! 21:30 explain (analyze, costs off, buffers) -- buffers is aprox about num of disk ops + ! b-tree index has nodes with like 100 children + ! 26:00 index only scan + ! Heap Fetches: 4 (pg went into table because of visibility/autovac) + ! 28:00 index on random uuid - will have more r/w + ! because of randomizeness (pg optimized insert of sequential values) + ! !!! UUID v7 can generate sequential ones + ! select ... from users where state = 'PENDING' and name = ? + ! create index state_name_users on users(name) include(state) -- idx will not sort by state, just include it + ! create index of (col1, col2) -- index sorted on combination of state, name +Tenzor - Backend School - PG Indices p2 0:00 of 1:21:33 + https://www.youtube.com/watch?v=WTELBpLUb2E +Tenzor - Backend School - PG Indices p1 0:00 of 1:10:44 + https://www.youtube.com/watch?v=sNCKlklvGO0 +2017 +BartunovKorotkov - All truth about Indices 0:00 of 46:35 + https://www.youtube.com/watch?v=aaecM4wKdhY diff --git a/db/sql/postgres/feature/index/reindex.txt b/db/sql/postgres/feature/performance/index/reindex.txt similarity index 100% rename from db/sql/postgres/feature/index/reindex.txt rename to db/sql/postgres/feature/performance/index/reindex.txt diff --git a/db/sql/postgres/feature/index/types.txt b/db/sql/postgres/feature/performance/index/types.txt similarity index 100% rename from db/sql/postgres/feature/index/types.txt rename to db/sql/postgres/feature/performance/index/types.txt diff --git a/db/sql/postgres/feature/index/unique.txt b/db/sql/postgres/feature/performance/index/unique.txt similarity index 100% rename from db/sql/postgres/feature/index/unique.txt rename to db/sql/postgres/feature/performance/index/unique.txt diff --git a/db/sql/postgres/feature/performance/hints-directions-query-planner.txt b/db/sql/postgres/feature/performance/planner/hints-directions-query-planner.txt similarity index 100% rename from db/sql/postgres/feature/performance/hints-directions-query-planner.txt rename to db/sql/postgres/feature/performance/planner/hints-directions-query-planner.txt diff --git a/db/sql/postgres/feature/performance/presentations.txt b/db/sql/postgres/feature/performance/presentations.txt deleted file mode 100644 index 4d8c0d873..000000000 --- a/db/sql/postgres/feature/performance/presentations.txt +++ /dev/null @@ -1,6 +0,0 @@ -2024 -JPoint - Zhilin - PG Can Make a Pain 0:00 of 45:49 - https://www.youtube.com/watch?v=pTWfjyeQ5Ks - https://jokerconf.com/talks/0bd645ad3a0f48c292547db572a1c7eb -WorkSolutions - Kostenko - Postgres World Optimization Misteries ru 0:00 of 32:50 - https://www.youtube.com/watch?v=MeTDmLyYD9k diff --git a/db/sql/postgres/feature/performance/tools/dalibo-pev2.txt b/db/sql/postgres/feature/performance/tools/dalibo-pev2.txt new file mode 100644 index 000000000..5056167f7 --- /dev/null +++ b/db/sql/postgres/feature/performance/tools/dalibo-pev2.txt @@ -0,0 +1,5 @@ +https://explain.dalibo.com/ + psql -XqAt -f explain.sql > analyze.json + +https://github.com/dalibo/pev2 + https://github.com/AlexTatiyants/pev diff --git a/db/sql/postgres/feature/index/tools/pg-index-health-java.txt b/db/sql/postgres/feature/performance/tools/pg-index-health-java.txt similarity index 100% rename from db/sql/postgres/feature/index/tools/pg-index-health-java.txt rename to db/sql/postgres/feature/performance/tools/pg-index-health-java.txt diff --git a/db/sql/postgres/feature/performance/tools/plan-exporter.txt b/db/sql/postgres/feature/performance/tools/plan-exporter.txt new file mode 100644 index 000000000..33f1d4026 --- /dev/null +++ b/db/sql/postgres/feature/performance/tools/plan-exporter.txt @@ -0,0 +1 @@ +https://github.com/agneum/plan-exporter diff --git a/db/sql/postgres/feature/performance/tensor-explain.txt b/db/sql/postgres/feature/performance/tools/tensor-explain.txt similarity index 100% rename from db/sql/postgres/feature/performance/tensor-explain.txt rename to db/sql/postgres/feature/performance/tools/tensor-explain.txt diff --git a/db/sql/postgres/feature/transaction/locks.txt b/db/sql/postgres/feature/transaction/locks.txt index 299539846..ebd2ad4cf 100644 --- a/db/sql/postgres/feature/transaction/locks.txt +++ b/db/sql/postgres/feature/transaction/locks.txt @@ -6,6 +6,9 @@ https://www.citusdata.com/blog/2018/02/22/seven-tips-for-dealing-with-postgres-l https://habr.com/ru/company/otus/blog/452986/ 2015 https://habrahabr.ru/company/postgrespro/blog/270827/ +2012 +https://www.youtube.com/watch?v=s3ee0nuDDqs + https://momjian.us/main/writings/pgsql/locking.pdf samples select ... for update; diff --git a/science/ai/free/deepsek.txt b/science/ai/free/deepsek.txt new file mode 100644 index 000000000..9bfef7861 --- /dev/null +++ b/science/ai/free/deepsek.txt @@ -0,0 +1,7 @@ +https://www.deepseek.com/ +https://github.com/deepseek-ai +https://api-docs.deepseek.com/quick_start/pricing + +2025 +Makarov - DeepSeq v3 now free 0:00 of 6:29 + https://www.youtube.com/watch?v=cNXTGOy6FQQ