{"id":30900,"date":"2019-10-31T21:38:02","date_gmt":"2019-10-31T18:38:02","guid":{"rendered":"https:\/\/prohoster.info\/blog\/parallelnye-zaprosy-v-postgresql\/"},"modified":"2019-10-31T21:38:02","modified_gmt":"2019-10-31T18:38:02","slug":"parallelnye-zaprosy-v-postgresql","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/parallelnye-zaprosy-v-postgresql","title":{"rendered":"K\u00ebrkesat paralele n\u00eb PostgreSQL","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"K\u00ebrkesat paralele n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2019\/04\/bbb4b4d3f8714bbdb9b26ada2f2253b5.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nN\u00eb procesor\u00ebt modern\u00eb ka shum\u00eb b\u00ebrthama. P\u00ebr vite me radh\u00eb, aplikacionet d\u00ebrgojn\u00eb k\u00ebrkesa n\u00eb bazat e t\u00eb dh\u00ebnave n\u00eb m\u00ebnyr\u00eb paralele. N\u00ebse ky \u00ebsht\u00eb nj\u00eb k\u00ebrkes\u00eb raporti p\u00ebr shum\u00eb rreshta n\u00eb tabel\u00eb, ajo ekzekutohet m\u00eb shpejt kur angazhon disa procesor\u00eb, dhe n\u00eb PostgreSQL kjo \u00ebsht\u00eb e mundur q\u00eb nga versioni 9.6.<\/p>\n<p><\/p>\n<p>K\u00ebrkoi 3 vite p\u00ebr t\u00eb realizuar funksionin e k\u00ebrkesave paralele \u2014 duhej t\u00eb ri-shkruhej kodi n\u00eb faza t\u00eb ndryshme t\u00eb ekzekutimit t\u00eb k\u00ebrkesave. N\u00eb PostgreSQL 9.6 u krijua infrastruktura p\u00ebr p\u00ebrmir\u00ebsimin e m\u00ebtejsh\u00ebm t\u00eb kodit. N\u00eb versionet pasuese, dhe lloje t\u00eb tjera k\u00ebrkesash ekzekutohen n\u00eb m\u00ebnyr\u00eb paralele.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h3 id=\"ogranicheniya\">Kufizimet<\/h3>\n<p><\/p>\n<ul>\n<li>Mos aktivizoni ekzekutimin paralel n\u00ebse t\u00eb gjitha b\u00ebrtham\u00ebn jan\u00eb t\u00eb z\u00ebna, p\u00ebrndryshe k\u00ebrkesat e tjera do t\u00eb ngadal\u00ebsohen.<\/li>\n<li>E r\u00ebnd\u00ebsishme, p\u00ebrpunimi paralel me vlera t\u00eb larta t\u00eb WORK_MEM angazhon shum\u00eb memorie \u2014 \u00e7do lidhje h\u00ebzho ose renditje konsumon memorie n\u00eb volum t\u00eb work_mem.<\/li>\n<li>K\u00ebrkesat OLTP me vones\u00eb t\u00eb ul\u00ebt nuk mund t\u00eb p\u00ebrshpejtohen me ekzekutimin paralel. N\u00ebse nj\u00eb k\u00ebrkes\u00eb kthen nj\u00eb rresht, p\u00ebrpunimi paralel vet\u00ebm e ngadal\u00ebson at\u00eb.<\/li>\n<li>Zhvilluesve u p\u00eblqen t\u00eb p\u00ebrdorin benchmark TPC-H. Ndoshta keni k\u00ebrkesa t\u00eb ngjashme p\u00ebr ekzekutimin e p\u00ebrsosur paralel.<\/li>\n<li>Vet\u00ebm k\u00ebrkesat SELECT pa bllokim predikativ ekzekutohen n\u00eb m\u00ebnyr\u00eb paralele.<\/li>\n<li>Nganj\u00ebher\u00eb, indeksimi i sakt\u00eb \u00ebsht\u00eb m\u00eb mir\u00eb se skanimi sekondar n\u00eb m\u00ebnyr\u00eb paralele.<\/li>\n<li>Pejsazhet e k\u00ebrkesave dhe kursori nuk mb\u00ebshteten.<\/li>\n<li>Funksionet e dritareve dhe funksionet agregate t\u00eb grupeve t\u00eb renditura nuk jan\u00eb paralele.<\/li>\n<li>Nuk fitoni asgj\u00eb n\u00eb ngarkes\u00ebn e I\/O.<\/li>\n<li>Nuk ka algorithma t\u00eb paralelizuara t\u00eb renditjes. Por k\u00ebrkesat me renditje mund t\u00eb ekzekutohen paralelisht n\u00eb disa aspekte.<\/li>\n<li>Z\u00ebvend\u00ebso CTE (ME \u2026) me nj\u00eb SELECT t\u00eb ngulitur p\u00ebr t\u00eb p\u00ebrfshir\u00eb p\u00ebrpunimin paralel.<\/li>\n<li>P\u00ebrmbajtjet e t\u00eb dh\u00ebnave t\u00eb jashtme ende nuk mb\u00ebshtesin p\u00ebrpunimin paralel (edhe pse mund t\u00eb mb\u00ebshteteshin!)<\/li>\n<li>FULL OUTER JOIN nuk mb\u00ebshtetet.<\/li>\n<li>max_rows \u00e7aktivizon p\u00ebrpunimin paralel.<\/li>\n<li>N\u00ebse k\u00ebrkesa ka nj\u00eb funksion, i cili nuk \u00ebsht\u00eb e sh\u00ebnuar si PARALLEL SAFE, ajo do t\u00eb jet\u00eb nj\u00eb-kohore.<\/li>\n<li>Niveli i izolimit t\u00eb transaksionit SERIALIZABLE \u00e7aktivizon p\u00ebrpunimin paralel.<\/li>\n<\/ul>\n<p><\/p>\n<h3 id=\"testovaya-sreda\">Mjedisi i testimit<\/h3>\n<p><\/p>\n<p>Zhvilluesit e PostgreSQL u p\u00ebrpoq\u00ebn t\u00eb pak\u00ebsonin koh\u00ebn e p\u00ebrgjigjes p\u00ebr k\u00ebrkesat e benchmark-ut TPC-H. Shkarko benchmark-un dhe <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tvondra\/pg_tpch\">e adaptoje at\u00eb p\u00ebr PostgreSQL<\/a><\/noindex>. Ky \u00ebsht\u00eb nj\u00eb p\u00ebrdorim jozyrtar i benchmark-ut TPC-H \u2014 jo p\u00ebr t\u00eb krahasuar bazat e t\u00eb dh\u00ebnave ose pajisjet.<\/p>\n<p><\/p>\n<ol>\n<li>Shkarko TPC-H_Tools_v2.17.3.zip (apo versionin m\u00eb t\u00eb ri) <noindex><a rel=\"nofollow\" href=\"http:\/\/www.tpc.org\/tpc_documents_current_versions\/current_specifications.asp\">nga faqja zyrtare TPC<\/a><\/noindex>.<\/li>\n<li>Rivendos makefile.suite n\u00eb Makefile dhe ndrysho si \u00ebsht\u00eb p\u00ebrshkruar k\u00ebtu: <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tvondra\/pg_tpch\">https:\/\/github.com\/tvondra\/pg_tpch <\/a><\/noindex>. Kompliko kodin me komand\u00ebn make.<\/li>\n<li>Gjenere t\u00eb dh\u00ebnat: <code>.\/dbgen -s 10<\/code> krijon nj\u00eb baz\u00eb t\u00eb dh\u00ebnash prej 23 GB. Kjo do t\u00eb mjaftoj\u00eb p\u00ebr t\u00eb par\u00eb diferenc\u00ebn n\u00eb performanc\u00ebn e k\u00ebrkesave paralele dhe jo-paralele.<\/li>\n<li>Konverto skedar\u00ebt <code>tbl<\/code> n\u00eb <code>csv me for<\/code> dhe <code>sed<\/code>.<\/li>\n<li>Klononi depot <code>pg_tpch<\/code> dhe kopjo skedar\u00ebt <code>csv<\/code> n\u00eb <code>pg_tpch\/dss\/data<\/code>.<\/li>\n<li>Krijo k\u00ebrkesat me komand\u00ebn <code>qgen<\/code>.<\/li>\n<li>Ngarko t\u00eb dh\u00ebnat n\u00eb baz\u00eb me komand\u00ebn <code>.\/tpch.sh<\/code>.<\/li>\n<\/ol>\n<p><\/p>\n<h3 id=\"parallelnoe-posledovatelnoe-skanirovanie\">Skanimi paralel sekondar<\/h3>\n<p><\/p>\n<p>Ai mund t\u00eb jet\u00eb m\u00eb i shpejt\u00eb jo nga leximi paralel, por sepse t\u00eb dh\u00ebnat jan\u00eb shp\u00ebrndara n\u00eb shum\u00eb b\u00ebrthama t\u00eb procesorit. N\u00eb sistemet operuese moderne, skedar\u00ebt e t\u00eb dh\u00ebnave PostgreSQL jan\u00eb mir\u00eb t\u00eb ruajtur n\u00eb cache. Me leximin parashikues, mund t\u00eb merrni nga ruajtja nj\u00eb bllok m\u00eb shum\u00eb se sa k\u00ebrkon demon PG. Prandaj, performanca e k\u00ebrkes\u00ebs nuk kufizohet nga I\/O e diskut. Ai konsumon cikle t\u00eb procesorit p\u00ebr t\u00eb:<\/p>\n<p><\/p>\n<ul>\n<li>lexuar rreshta nj\u00eb nga nj\u00eb nga faqet e tabel\u00ebs;<\/li>\n<li>krahason vlerat e rreshtave dhe kushtet <code>WHERE<\/code>.<\/li>\n<\/ul>\n<p><\/p>\n<p>Ekzekuto nj\u00eb k\u00ebrkes\u00eb t\u00eb thjesht\u00eb <code>select<\/code>:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">tpch=# explain analyze select l_quantity as sum_qty from lineitem where l_shipdate &lt;= date &#039;1998-12-01&#039; - interval &#039;105&#039; day;\nQUERY PLAN\n--------------------------------------------------------------------------------------------------------------------------\nSkanimi Sekondar mbi lineitem (cost=0.00..1964772.00 rows=58856235 width=5) (actual time=0.014..16951.669 rows=58839715 loops=1)\nFiltri: (l_shipdate &lt;= &#039;1998-08-18 00:00:00&#039;::timestamp without time zone)\nRreshtat e hequra nga Filtri: 1146337\nKoha e Planifikimit: 0.203 ms\nKoha e Ekzekutimit: 19035.100 ms<\/code><\/pre>\n<p><\/p>\n<p>Skanimi sekondar jep shum\u00eb rreshta pa agregim, k\u00ebshtu q\u00eb k\u00ebrkesa ekzekutohet me nj\u00eb b\u00ebrtham\u00eb procesori.<\/p>\n<p><\/p>\n<p>N\u00ebse shtoni <code>SUM()<\/code>, \u00ebsht\u00eb e qart\u00eb se dy procese ndihm\u00ebs do t\u00eb ndihmojn\u00eb p\u00ebr t\u00eb p\u00ebrshpejtuar k\u00ebrkes\u00ebn:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">explain analyze select sum(l_quantity) as sum_qty from lineitem where l_shipdate &lt;= date &#039;1998-12-01&#039; - interval &#039;105&#039; day;\nQUERY PLAN\n----------------------------------------------------------------------------------------------------------------------------------------------------\nP\u00ebrfundimi i Agregimit (cost=1589702.14..1589702.15 rows=1 width=32) (actual time=8553.365..8553.365 rows=1 loops=1)\n-&gt; Grumbull (cost=1589701.91..1589702.12 rows=2 width=32) (actual time=8553.241..8555.067 rows=3 loops=1)\nPun\u00ebtor\u00eb t\u00eb Planifikuar: 2\nPun\u00ebtor\u00eb t\u00eb Lan\u00e7uar: 2\n-&gt; Agregimi i Pjes\u00ebs (cost=1588701.91..1588701.92 rows=1 width=32) (actual time=8547.546..8547.546 rows=1 loops=3)\n-&gt; Skanimi Sekondar Paralel mbi lineitem (cost=0.00..1527393.33 rows=24523431 width=5) (actual time=0.038..5998.417 rows=19613238 loops=3)\nFiltri: (l_shipdate &lt;= &#039;1998-08-18 00:00:00&#039;::timestamp without time zone)\nRreshtat e hequra nga Filtri: 382112\nKoha e Planifikimit: 0.241 ms\nKoha e Ekzekutimit: 8555.131 ms<\/code><\/pre>\n<p><\/p>\n<h3 id=\"parallelnaya-agregaciya\">Agregimi Paralel<\/h3>\n<p><\/p>\n<p>\u041d\u043e\u0434\u0430 &#171;Parallel Seq Scan&#187; \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438. \u041d\u043e\u0434\u0430 &#171;Partial Aggregate&#187; \u0443\u0440\u0435\u0437\u0430\u0435\u0442 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>SUM()<\/code>. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a SUM \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0434\u043e\u0439 &#171;Gather&#187;.<\/p>\n<p><\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0434\u043e\u0439 &#171;Finalize Aggregate&#187;. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0432\u043e\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u043a &#171;parallel safe&#187;.<\/p>\n<p><\/p>\n<h3 id=\"kolichestvo-rabochih-processov\">Numri i proceseve punuese<\/h3>\n<p><\/p>\n<p>Numri i proceseve punuese mund t\u00eb rritet pa e rinisur serverin:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">explain analyze select sum(l_quantity) as sum_qty from lineitem where l_shipdate &lt;= date &#039;1998-12-01&#039; - interval &#039;105&#039; day;\nQUERY PLAN\n----------------------------------------------------------------------------------------------------------------------------------------------------\nP\u00ebrfundimi i Agregimit (cost=1589702.14..1589702.15 rows=1 width=32) (actual time=8553.365..8553.365 rows=1 loops=1)\n-&gt; Grumbull (cost=1589701.91..1589702.12 rows=2 width=32) (actual time=8553.241..8555.067 rows=3 loops=1)\nPun\u00ebtor\u00eb t\u00eb Planifikuar: 2\nPun\u00ebtor\u00eb t\u00eb Lan\u00e7uar: 2\n-&gt; Agregimi i Pjes\u00ebs (cost=1588701.91..1588701.92 rows=1 width=32) (actual time=8547.546..8547.546 rows=1 loops=3)\n-&gt; Skanimi Sekondar Paralel mbi lineitem (cost=0.00..1527393.33 rows=24523431 width=5) (actual time=0.038..5998.417 rows=19613238 loops=3)\nFiltri: (l_shipdate &lt;= &#039;1998-08-18 00:00:00&#039;::timestamp without time zone)\nRreshtat e hequra nga Filtri: 382112\nKoha e Planifikimit: 0.241 ms\nKoha e Ekzekutimit: 8555.131 ms<\/code><\/pre>\n<p><\/p>\n<p>\u00c7far\u00eb po ndodh k\u00ebtu? Numri i proceseve punuese \u00ebsht\u00eb dyfishuar, nd\u00ebrsa k\u00ebrkesa u b\u00eb vet\u00ebm 1,6599 her\u00eb m\u00eb e shpejt\u00eb. Llogaritjet jan\u00eb interesante. Kishim 2 procese punuese dhe 1 lider. Pas ndryshimit, u b\u00eb 4+1.<\/p>\n<p><\/p>\n<p>Shpejt\u00ebsia maksimale q\u00eb arrijm\u00eb nga p\u00ebrpunimi paralel: 5\/3 = 1,66(6) her\u00eb.<\/p>\n<p><\/p>\n<h2 id=\"kak-eto-rabotaet\">Si funksionon?<\/h2>\n<p><\/p>\n<h3 id=\"processy\">Proceset<\/h3>\n<p><\/p>\n<p>Ekzekutimi i k\u00ebrkes\u00ebs fillon gjithmon\u00eb me procesin drejtues. Lideri b\u00ebn t\u00eb gjitha proceset jo-paralel dhe nj\u00eb pjes\u00eb t\u00eb p\u00ebrpunimit paralel. Proceset e tjera q\u00eb ekzekutojn\u00eb t\u00eb nj\u00ebjtat k\u00ebrkesa quhen procese punuese. P\u00ebrpunimi paralel p\u00ebrdor infrastruktur\u00ebn <noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/bgworker.html\">e proceseve punuese dinamike n\u00eb sfond<\/a><\/noindex> (nga versioni 9.4). Pasi pjes\u00ebt e tjera t\u00eb PostgreSQL p\u00ebrdorin procese dhe jo fijet, nj\u00eb k\u00ebrkes\u00eb me 3 procese punuese mund t\u00eb jet\u00eb 4 her\u00eb m\u00eb e shpejt\u00eb se p\u00ebrpunimi tradicional.<\/p>\n<p><\/p>\n<h3 id=\"vzaimodeystvie\">Nd\u00ebrveprimi<\/h3>\n<p><\/p>\n<p>Proceset punuese komunikojn\u00eb me liderin p\u00ebrmes nj\u00eb rrethi mesazhe (bazuar n\u00eb memorie t\u00eb p\u00ebrbashk\u00ebt). \u00c7do proces ka 2 rreth mesazhesh: p\u00ebr gabime dhe p\u00ebr tuple.<\/p>\n<p><\/p>\n<h3 id=\"skolko-nuzhno-rabochih-processov\">Sa procese punuese nevojiten?<\/h3>\n<p><\/p>\n<p>Kufizimi minimal caktohet nga parametri <noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/runtime-config-resource.html#GUC-MAX-PARALLEL-WORKERS-PER-GATHER\"><code>max_parallel_workers_per_gather<\/code><\/a><\/noindex>. Pastaj ekzekutori i k\u00ebrkesave merr proceset punuese nga puli, i kufizuar nga parametri <noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES\"><code>max_parallel_workers size<\/code><\/a><\/noindex>. Kufizimi i fundit \u00ebsht\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES\"><code>max_worker_processes<\/code><\/a><\/noindex>, pra numri total i proceseve t\u00eb sfondit.<\/p>\n<p><\/p>\n<p>N\u00ebse nuk arrihet ndarja e nj\u00eb procesi punues, p\u00ebrpunimi do t\u00eb jet\u00eb me nj\u00eb proces.<\/p>\n<p><\/p>\n<p>Planifikuesi i k\u00ebrkesave mund t\u00eb zvog\u00ebloj\u00eb proceset punuese n\u00eb var\u00ebsi t\u00eb madh\u00ebsis\u00eb s\u00eb tabel\u00ebs ose indekseve. P\u00ebr k\u00ebt\u00eb ka parametra <noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/current\/runtime-config-query.html#GUC-MIN-PARALLEL-TABLE-SCAN-SIZE\"><code>min_parallel_table_scan_size<\/code><\/a><\/noindex> dhe <noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/current\/runtime-config-query.html#GUC-MIN-PARALLEL-INDEX-SCAN-SIZE\"><code>min_parallel_index_scan_size<\/code><\/a><\/noindex>.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">set min_parallel_table_scan_size='8MB'\n8MB tabel\u00eb =&gt; 1 punonj\u00ebs\n24MB tabel\u00eb =&gt; 2 punonj\u00ebs\n72MB tabel\u00eb =&gt; 3 punonj\u00ebs\nx =&gt; log(x \/ min_parallel_table_scan_size) \/ log(3) + 1 punonj\u00ebs<\/code><\/pre>\n<p><\/p>\n<p>\u00c7do her\u00eb q\u00eb tabela \u00ebsht\u00eb 3 her\u00eb m\u00eb e madhe se <code>min_parallel_(index|table)_scan_size<\/code>, Postgres shton nj\u00eb proces punues. Numri i proceseve punuese nuk bazohet n\u00eb kosto. Var\u00ebsia e rrethit e v\u00ebshtir\u00ebson realizimet e komplikuara. N\u00eb vend t\u00eb k\u00ebsaj, planifikuesi p\u00ebrdor rregulla t\u00eb thjeshta.<\/p>\n<p><\/p>\n<p>N\u00eb praktik\u00eb, k\u00ebto rregulla nuk jan\u00eb gjithmon\u00eb t\u00eb p\u00ebrshtatshme p\u00ebr prodhim, k\u00ebshtu q\u00eb \u00ebsht\u00eb e mundur t\u00eb ndryshohet numri i proceseve punuese p\u00ebr nj\u00eb tabel\u00eb specifike: ALTER TABLE \u2026 SET (<code>parallel_workers = N<\/code>).<\/p>\n<p><\/p>\n<h3 id=\"pochemu-parallelnaya-obrabotka-ne-ispolzuetsya\">Pse nuk p\u00ebrdoret p\u00ebrpunimi paralel?<\/h3>\n<p><\/p>\n<p>P\u00ebrve\u00e7 list\u00ebs s\u00eb gjat\u00eb t\u00eb kufizimeve ka edhe kontrollime kostoje:<\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/current\/runtime-config-query.html#GUC-PARALLEL-SETUP-COST\"><code>parallel_setup_cost<\/code><\/a><\/noindex> \u2014 p\u00ebr t\u00eb shmangur p\u00ebrpunimin paralel t\u00eb k\u00ebrkesave t\u00eb shkurtra. Ky parametr koston koh\u00ebn p\u00ebr t\u00eb p\u00ebrgatitur memorien, p\u00ebr t\u00eb nisur procesin dhe p\u00ebr shk\u00ebmbimin fillestar t\u00eb t\u00eb dh\u00ebnave.<\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/current\/runtime-config-query.html#GUC-PARALLEL-TUPLE-COST\"><code>parallel_tuple_cost<\/code><\/a><\/noindex>: komunikimi midis liderit dhe punonj\u00ebsve mund t\u00eb zgjas\u00eb n\u00eb proporcioni me numrin e tupleve nga proceset punuese. Ky parametr llogarit kostot p\u00ebr shk\u00ebmbimin e t\u00eb dh\u00ebnave.<\/p>\n<p><\/p>\n<h3 id=\"soedineniya-vlozhennyh-ciklov--nested-loop-join\">Bashkimet e cikleve t\u00eb thella \u2014 Nested Loop Join<\/h3>\n<p><\/p>\n<pre><code class=\"plaintext\">PostgreSQL 9.6+ \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0446\u0438\u043a\u043b\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f.\n\nexplain (costs off) select c_custkey, count(o_orderkey)\n                from    customer left outer join orders on\n                                c_custkey = o_custkey and o_comment not like '%special%deposits%'\n                group by c_custkey;\n                                      QUERY PLAN\n--------------------------------------------------------------------------------------\n Finalize GroupAggregate\n   Group Key: customer.c_custkey\n   -&gt;  Gather Merge\n         Workers Planned: 4\n         -&gt;  Partial GroupAggregate\n               Group Key: customer.c_custkey\n               -&gt;  Nested Loop Left Join\n                     -&gt;  Parallel Index Only Scan using customer_pkey on customer\n                     -&gt;  Index Scan using idx_orders_custkey on orders\n                           Index Cond: (customer.c_custkey = o_custkey)\n                           Filter: ((o_comment)::text !~~ '%special%deposits%'::text)<\/code><\/pre>\n<p><\/p>\n<p>Grupi formohet n\u00eb faz\u00ebn e fundit, k\u00ebshtu q\u00eb Nested Loop Left Join \u00ebsht\u00eb nj\u00eb operacion paralel. Parallel Index Only Scan \u00ebsht\u00eb paraqitur vet\u00ebm n\u00eb versionin 10. Ai funksionon n\u00eb m\u00ebnyr\u00eb t\u00eb ngjashme me skanimin paralel sekondar. Kushti <code>c_custkey = o_custkey<\/code> lexon nj\u00eb rend nga \u00e7do rresht t\u00eb klientit. Pra, ai nuk \u00ebsht\u00eb paralel.<\/p>\n<p><\/p>\n<h3 id=\"hesh-soedinenie--hash-join\">Bashkim me Hash \u2014 Hash Join<\/h3>\n<p><\/p>\n<p>\u00c7do proces punues krijon tabel\u00ebn e tij t\u00eb hash deri n\u00eb PostgreSQL 11. Dhe n\u00ebse k\u00ebto procese jan\u00eb m\u00eb shum\u00eb se kat\u00ebr, performanca nuk p\u00ebrmir\u00ebsohet. N\u00eb versionin e ri, tabela e hash-it \u00ebsht\u00eb e p\u00ebrbashk\u00ebt. \u00c7do proces punues mund t\u00eb p\u00ebrdor\u00eb WORK_MEM p\u00ebr t\u00eb krijuar nj\u00eb tabel\u00eb hash.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">select\n        l_shipmode,\n        sum(case\n                when o_orderpriority = '1-URGENT'\n                        or o_orderpriority = '2-HIGH'\n                        then 1\n                else 0\n        end) as high_line_count,\n        sum(case\n                when o_orderpriority  '1-URGENT'\n                        and o_orderpriority  '2-HIGH'\n                        then 1\n                else 0\n        end) as low_line_count\nfrom\n        orders,\n        lineitem\nwhere\n        o_orderkey = l_orderkey\n        and l_shipmode in ('MAIL', 'AIR')\n        and l_commitdate &lt; l_receiptdate\n        and l_shipdate = date '1996-01-01'\n        and l_receiptdate   Finalize GroupAggregate  (cost=1964755.66..1966196.11 rows=7 width=27) (actual time=7579.590..7579.591 rows=1 loops=1)\n         Group Key: lineitem.l_shipmode\n         -&gt;  Gather Merge  (cost=1964755.66..1966195.83 rows=28 width=27) (actual time=7559.593..7922.319 rows=6 loops=1)\n               Workers Planned: 4\n               Workers Launched: 4\n               -&gt;  Partial GroupAggregate  (cost=1963755.61..1965192.44 rows=7 width=27) (actual time=7548.103..7564.592 rows=2 loops=5)\n                     Group Key: lineitem.l_shipmode\n                     -&gt;  Sort  (cost=1963755.61..1963935.20 rows=71838 width=27) (actual time=7530.280..7539.688 rows=62519 loops=5)\n                           Sort Key: lineitem.l_shipmode\n                           Sort Method: external merge  Disk: 2304kB\n                           Worker 0:  Sort Method: external merge  Disk: 2064kB\n                           Worker 1:  Sort Method: external merge  Disk: 2384kB\n                           Worker 2:  Sort Method: external merge  Disk: 2264kB\n                           Worker 3:  Sort Method: external merge  Disk: 2336kB\n                           -&gt;  Parallel Hash Join  (cost=382571.01..1957960.99 rows=71838 width=27) (actual time=7036.917..7499.692 rows=62519 loops=5)\n                                 Hash Cond: (lineitem.l_orderkey = orders.o_orderkey)\n                                 -&gt;  Parallel Seq Scan on lineitem  (cost=0.00..1552386.40 rows=71838 width=19) (actual time=0.583..4901.063 rows=62519 loops=5)\n                                       Filter: ((l_shipmode = ANY ('{MAIL,AIR}'::bpchar[])) AND (l_commitdate &lt; l_receiptdate) AND (l_shipdate = '1996-01-01'::date) AND (l_receiptdate   Parallel Hash  (cost=313722.45..313722.45 rows=3750045 width=20) (actual time=2011.518..2011.518 rows=3000000 loops=5)\n                                       Buckets: 65536  Batches: 256  Memory Usage: 3840kB\n                                       -&gt;  Parallel Seq Scan on orders  (cost=0.00..313722.45 rows=3750045 width=20) (actual time=0.029..995.948 rows=3000000 loops=5)\n Planning Time: 0.977 ms\n Execution Time: 7923.770 ms<\/code><\/pre>\n<p><\/p>\n<p>K\u00ebrkesa 12 nga TPC-H ilustron qart\u00eb bashkimin e realizuar me hash n\u00eb m\u00ebnyr\u00eb t\u00eb paralel. \u00c7do proces pun\u00ebtor merr pjes\u00eb n\u00eb krijimin e nj\u00eb tabele hash t\u00eb p\u00ebrbashk\u00ebt.<\/p>\n<p><\/p>\n<h3 id=\"soedinenie-sliyaniem--merge-join\">Bashkimi me shkrirje \u2014 Merge Join<\/h3>\n<p><\/p>\n<p>Bashkimi me shkrirje ka karakteristika jo-paralele. Mos u shqet\u00ebsoni n\u00ebse ky \u00ebsht\u00eb hapi i fundit i k\u00ebrkes\u00ebs, \u2014 ai mund t\u00eb ekzekutohet gjith\u00ebsesi n\u00eb m\u00ebnyr\u00eb paralele.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">-- K&euml;rkesa 2 nga TPC-H\nshpjego (kostot jasht&euml;) p&euml;rzgjedh s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment\nnga    part, supplier, partsupp, nation, region\nku\n        p_partkey = ps_partkey\n        dhe s_suppkey = ps_suppkey\n        dhe p_size = 36\n        dhe p_type si &#039;%BRASS&#039;\n        dhe s_nationkey = n_nationkey\n        dhe n_regionkey = r_regionkey\n        dhe r_name = &#039;AMERIKA&#039;\n        dhe ps_supplycost = (\n                p&euml;rzgjedh\n                        min(ps_supplycost)\n                nga    partsupp, supplier, nation, region\n                ku\n                        p_partkey = ps_partkey\n                        dhe s_suppkey = ps_suppkey\n                        dhe s_nationkey = n_nationkey\n                        dhe n_regionkey = r_regionkey\n                        dhe r_name = &#039;AMERIKA&#039;\n        )\nrendit sipas s_acctbal zbrit&euml;s, n_name, s_name, p_partkey\nLIMIT 100;\n                                                PLANNA E K&Euml;RKES&Euml;S\n----------------------------------------------------------------------------------------------------------\n Limit\n   -&amp;gt;  Rendit\n         &Ccedil;el&euml;si i Rendit: supplier.s_acctbal ZBRIT&Euml;S, nation.n_name, supplier.s_name, part.p_partkey\n         -&amp;gt;  Bashkimi i Bashk&euml;ve\n               Kushti i Bashkimit: (part.p_partkey = partsupp.ps_partkey)\n               Filtri i Bashkimit: (partsupp.ps_supplycost = (SubPlani 1))\n               -&amp;gt;  Mbledhja e Bashkimeve\n                     Pun&euml;tor&euml; t&euml; Planifikuar: 4\n                     -&amp;gt;  Skemi Paralele e Indeksit duke p&euml;rdorur &lt;strong&gt;part_pkey&lt;\/strong&gt; n&euml; pjes&euml;\n                           Filtri: (((p_type)::text ~~ &#039;%BRASS&#039;::text) DHE (p_size = 36))\n               -&amp;gt;  Materializo\n                     -&amp;gt;  Rendit\n                           &Ccedil;el&euml;si i Rendit: partsupp.ps_partkey\n                           -&amp;gt;  Cikli i Foleve\n                                 -&amp;gt;  Cikli i Foleve\n                                       Filtri i Bashkimit: (nation.n_regionkey = region.r_regionkey)\n                                       -&amp;gt;  Skemi Sekuencial n&euml; region\n                                             Filtri: (r_name = &#039;AMERIKA&#039;::bpchar)\n                                       -&amp;gt;  Bashkimi i Hash\n                                             Kushti i Hash: (supplier.s_nationkey = nation.n_nationkey)\n                                             -&amp;gt;  Skemi Sekuencial n&euml; supplier\n                                             -&amp;gt;  Hash\n                                                   -&amp;gt;  Skemi Sekuencial n&euml; nation\n                                 -&amp;gt;  Skemi Indeksi duke p&euml;rdorur idx_partsupp_suppkey n&euml; partsupp\n                                       Kushti i Indeksit: (ps_suppkey = supplier.s_suppkey)\n               SubPlani 1\n                 -&amp;gt;  Agregati\n                       -&amp;gt;  Cikli i Foleve\n                             Filtri i Bashkimit: (nation_1.n_regionkey = region_1.r_regionkey)\n                             -&amp;gt;  Skemi Sekuencial n&euml; region region_1\n                                   Filtri: (r_name = &#039;AMERIKA&#039;::bpchar)\n                             -&amp;gt;  Cikli i Foleve\n                                   -&amp;gt;  Cikli i Foleve\n                                         -&amp;gt;  Skemi Indeksi duke p&euml;rdorur idx_partsupp_partkey n&euml; partsupp partsupp_1\n                                               Kushti i Indeksit: (part.p_partkey = ps_partkey)\n                                         -&amp;gt;  Skemi Indeksi duke p&euml;rdorur supplier_pkey n&euml; supplier supplier_1\n                                               Kushti i Indeksit: (s_suppkey = partsupp_1.ps_suppkey)\n                                   -&amp;gt;  Skemi Indeksi duke p&euml;rdorur nation_pkey n&euml; nation nation_1\n                                         Kushti i Indeksit: (n_nationkey = supplier_1.s_nationkey)<\/code><\/pre>\n<p><\/p>\n<p>\u041d\u043e\u0434\u0430 &#171;Merge Join&#187; \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0434 &#171;Gather Merge&#187;. \u0422\u0430\u043a \u0447\u0442\u043e \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u041d\u043e \u043d\u043e\u0434\u0430 &#171;Parallel Index Scan&#187; \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u043c <code>part_pkey<\/code>.<\/p>\n<p><\/p>\n<h3 id=\"soedinenie-po-sekciyam\">Bashkimi sipas seksioneve<\/h3>\n<p><\/p>\n<p>N\u00eb PostgreSQL 11 <noindex><a rel=\"nofollow\" href=\"http:\/\/ashutoshpg.blogspot.com\/2017\/12\/partition-wise-joins-divide-and-conquer.html\">bashkimi sipas seksioneve<\/a><\/noindex> \u00e7aktivizuar n\u00eb m\u00ebnyr\u00eb t\u00eb parazgjedhur: ka nj\u00eb planifikim shum\u00eb t\u00eb shtrenjt\u00eb. Tabelat me seksionim t\u00eb ngjash\u00ebm mund t\u00eb bashkohen seksion pas seksioni. K\u00ebshtu, Postgres do t\u00eb p\u00ebrdor\u00eb tabela hesh t\u00eb vogla. \u00c7do bashkim seksionesh mund t\u00eb jet\u00eb paralel.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">tpch=# set enable_partitionwise_join=t;\ntpch=# explain (costs off) select * from prt1 t1, prt2 t2\nwhere t1.a = t2.b and t1.b = 0 and t2.b between 0 and 10000;\n                    PLANI I K\u00cbRQESJES\n---------------------------------------------------\n Shtes\u00eb\n   -&gt;  Bashkimi Hash\n         Kusht Hash: (t2.b = t1.a)\n         -&gt;  Skanim Sekuencial n\u00eb prt2_p1 t2\n               Filtri: ((b &gt;= 0) DHE (b &lt;= 10000))\n         -&gt;  Hesh\n               -&gt;  Skanim Sekuencial n\u00eb prt1_p1 t1\n                     Filtri: (b = 0)\n   -&gt;  Bashkimi Hash\n         Kusht Hash: (t2_1.b = t1_1.a)\n         -&gt;  Skanim Sekuencial n\u00eb prt2_p2 t2_1\n               Filtri: ((b &gt;= 0) DHE (b &lt;= 10000))\n         -&gt;  Hesh\n               -&gt;  Skanim Sekuencial n\u00eb prt1_p2 t1_1\n                     Filtri: (b = 0)\ntpch=# set parallel_setup_cost = 1;\ntpch=# set parallel_tuple_cost = 0.01;\ntpch=# explain (costs off) select * from prt1 t1, prt2 t2\nwhere t1.a = t2.b and t1.b = 0 and t2.b between 0 and 10000;\n                        PLANI I K\u00cbRQESJES\n-----------------------------------------------------------\n Mblidhen\n   Punonj\u00ebsit e Planifikuar: 4\n   -&gt;  Shtes\u00eb Paralel\n         -&gt;  Bashkimi Hash Paralel\n               Kusht Hash: (t2_1.b = t1_1.a)\n               -&gt;  Skanim Sekuencial Paralel n\u00eb prt2_p2 t2_1\n                     Filtri: ((b &gt;= 0) DHE (b &lt;= 10000))\n               -&gt;  Hesh Paralel\n                     -&gt;  Skanim Sekuencial Paralel n\u00eb prt1_p2 t1_1\n                           Filtri: (b = 0)\n         -&gt;  Bashkimi Hash Paralel\n               Kusht Hash: (t2.b = t1.a)\n               -&gt;  Skanim Sekuencial Paralel n\u00eb prt2_p1 t2\n                     Filtri: ((b &gt;= 0) DHE (b &lt;= 10000))\n               -&gt;  Hesh Paralel\n                     -&gt;  Skanim Sekuencial Paralel n\u00eb prt1_p1 t1\n                           Filtri: (b = 0)<\/code><\/pre>\n<p><\/p>\n<p>E r\u00ebnd\u00ebsishme, bashkimi sipas seksioneve \u00ebsht\u00eb paralel vet\u00ebm n\u00ebse k\u00ebto seksione jan\u00eb mjaft t\u00eb m\u00ebdha.<\/p>\n<p><\/p>\n<h3 id=\"parallelnoe-dopolnenie--parallel-append\">Shtes\u00eb Paralel \u2014 Parallel Append<\/h3>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/parallel-plans.html#PARALLEL-APPEND\">Shtes\u00eb Paralel<\/a><\/noindex> mund t\u00eb p\u00ebrdoret n\u00eb vend t\u00eb blloqeve t\u00eb ndryshme n\u00eb procese t\u00eb ndryshme. Zakonisht ndodh kjo me k\u00ebrkesat UNION ALL. Disavantazhi \u2014 m\u00eb pak paraleliz\u00ebm, pasi \u00e7do proces p\u00ebrpunon vet\u00ebm 1 k\u00ebrkes\u00eb.<\/p>\n<p><\/p>\n<p>K\u00ebtu jan\u00eb aktivizuar 2 procese, ndon\u00ebse jan\u00eb planifikuar 4.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">tpch=# explain (costs off) select sum(l_quantity) as sum_qty from lineitem where l_shipdate &lt;= date &#039;1998-12-01&#039; - interval &#039;105&#039; day union all select sum(l_quantity) as sum_qty from lineitem where l_shipdate &lt;= date &#039;2000-12-01&#039; - interval &#039;105&#039; day;\n                                           QUERY PLAN\n------------------------------------------------------------------------------------------------\n Gather\n   Workers Planned: 2\n   -&gt;  Parallel Append\n         -&gt;  Aggregate\n               -&gt;  Seq Scan on lineitem\n                     Filter: (l_shipdate &lt;= &#039;2000-08-18 00:00:00&#039;::timestamp without time zone)\n         -&gt;  Aggregate\n               -&gt;  Seq Scan on lineitem lineitem_1\n                     Filter: (l_shipdate &lt;= &#039;1998-08-18 00:00:00&#039;::timestamp without time zone)<\/code><\/pre>\n<p><\/p>\n<h3 id=\"samye-vazhnye-peremennye\">Variablat m\u00eb t\u00eb r\u00ebnd\u00ebsishme<\/h3>\n<p><\/p>\n<ul>\n<li>WORK_MEM kufizon sasin\u00eb e memories p\u00ebr \u00e7do proces, jo vet\u00ebm p\u00ebr k\u00ebrkesat: work_mem <em> proceset <\/em> konneksionet = shum\u00eb memoria.<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/runtime-config-resource.html#GUC-MAX-PARALLEL-WORKERS-PER-GATHER\"><code>max_parallel_workers_per_gather<\/code><\/a><\/noindex> \u2014 sa shum\u00eb procese punuese do t\u00eb p\u00ebrdor\u00eb programi p\u00ebr procesimin paralel nga plani.<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES\"><code>max_worker_processes<\/code><\/a><\/noindex> \u2014 p\u00ebrshtat numrin total t\u00eb proceseve punuese me numrin e b\u00ebrthamave t\u00eb CPU n\u00eb server.<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES\"><code>max_parallel_workers<\/code><\/a><\/noindex> \u2014 e nj\u00ebjta, por p\u00ebr proceset punuese paralel.<\/li>\n<\/ul>\n<p><\/p>\n<h3 id=\"itogi\">P\u00ebrfundimet<\/h3>\n<p><\/p>\n<p>Q\u00eb nga versioni 9.6, procesimi paralel mund t\u00eb p\u00ebrmir\u00ebsoj\u00eb ndjesh\u00ebm performanc\u00ebn e k\u00ebrkesave t\u00eb komplikuara q\u00eb skanojn\u00eb shum\u00eb rreshta ose indekse. N\u00eb PostgreSQL 10 procesimi paralel \u00ebsht\u00eb aktivizuar si parazgjedhje. Mos harroni ta \u00e7aktivizoni n\u00eb server\u00ebt me ngarkes\u00eb t\u00eb lart\u00eb OLTP. Skanat sekondar ose skanat e indekseve konsumojn\u00eb shum\u00eb burime. N\u00ebse nuk po kryeni nj\u00eb raport mbi t\u00eb gjith\u00eb grumbullin e t\u00eb dh\u00ebnave, k\u00ebrkesat mund t\u00eb b\u00ebhen m\u00eb efikase thjesht duke shtuar indekset q\u00eb mungojn\u00eb ose duke p\u00ebrdorur ndarjen e duhur.<\/p>\n<p><\/p>\n<h3 id=\"ssylki\">Linke<\/h3>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/how-parallel-query-works.html\">https:\/\/www.postgresql.org\/docs\/11\/how-parallel-query-works.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/11\/parallel-plans.html\">https:\/\/www.postgresql.org\/docs\/11\/parallel-plans.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/ashutoshpg.blogspot.com\/2017\/12\/partition-wise-joins-divide-and-conquer.html\">http:\/\/ashutoshpg.blogspot.com\/2017\/12\/partition-wise-joins-divide-and-conquer.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/rhaas.blogspot.com\/2016\/04\/postgresql-96-with-parallel-query-vs.html\">http:\/\/rhaas.blogspot.com\/2016\/04\/postgresql-96-with-parallel-query-vs.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/amitkapila16.blogspot.com\/2015\/11\/parallel-sequential-scans-in-play.html\">http:\/\/amitkapila16.blogspot.com\/2015\/11\/parallel-sequential-scans-in-play.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/write-skew.blogspot.com\/2018\/01\/parallel-hash-for-postgresql.html\">https:\/\/write-skew.blogspot.com\/2018\/01\/parallel-hash-for-postgresql.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/rhaas.blogspot.com\/2017\/03\/parallel-query-v2.html\">http:\/\/rhaas.blogspot.com\/2017\/03\/parallel-query-v2.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/blog.2ndquadrant.com\/parallel-monster-benchmark\/\">https:\/\/blog.2ndquadrant.com\/parallel-monster-benchmark\/<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/blog.2ndquadrant.com\/parallel-aggregate\/\">https:\/\/blog.2ndquadrant.com\/parallel-aggregate\/<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.depesz.com\/2018\/02\/12\/waiting-for-postgresql-11-support-parallel-btree-index-builds\/\">https:\/\/www.depesz.com\/2018\/02\/12\/waiting-for-postgresql-11-support-parallel-btree-index-builds\/<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/youtu.be\/jWIOZzezbb8\">Paralelizmi n\u00eb PostgreSQL 11<\/a><\/noindex><\/li>\n<\/ul>\n<p>Burimi: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/southbridge\/blog\/446706\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0426\u041f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u044f\u0434\u0435\u0440. \u0413\u043e\u0434\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u044b\u043b\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0442\u0447\u0435\u0442\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0426\u041f, \u0438 \u0432 PostgreSQL \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 9.6. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c 3 \u0433\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":22879,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-30900","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0426\u041f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u044f\u0434\u0435\u0440. \u0413\u043e\u0434\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u044b\u043b\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0442\u0447\u0435\u0442\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0426\u041f, \u0438 \u0432 PostgreSQL \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 9.6. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c 3 \u0433\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/parallelnye-zaprosy-v-postgresql\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"sq_AL\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 PostgreSQL | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0426\u041f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u044f\u0434\u0435\u0440. \u0413\u043e\u0434\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u044b\u043b\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0442\u0447\u0435\u0442\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0426\u041f, \u0438 \u0432 PostgreSQL \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 9.6. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c 3 \u0433\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/parallelnye-zaprosy-v-postgresql\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T18:38:02+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T18:38:02+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47K\u00ebrkesat paralel n\u00eb PostgreSQL | ProHoster","description":"N\u00eb CPU-t\u00eb moderne ka shum\u00eb b\u00ebrthama. Vit pas viti, aplikacionet d\u00ebrgojn\u00eb k\u00ebrkesa n\u00eb bazat e t\u00eb dh\u00ebnave paralelisht. N\u00ebse kjo \u00ebsht\u00eb nj\u00eb k\u00ebrkes\u00eb raportuese p\u00ebr shum\u00eb rreshta n\u00eb nj\u00eb tabel\u00eb, ajo ekzekutohet m\u00eb shpejt kur aktivizohen disa CPU, dhe kjo \u00ebsht\u00eb e mundur n\u00eb PostgreSQL q\u00eb nga versioni 9.6. Duhej 3 vjet p\u00ebr t\u00eb realizuar funksionin e k\u00ebrkesave paralel \u2014 dhe duhej rishkruar kodi n\u00eb faza t\u00eb ndryshme t\u00eb ekzekutimit.","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/parallelnye-zaprosy-v-postgresql","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"sq_AL","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 PostgreSQL | ProHoster","og:description":"\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0426\u041f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u044f\u0434\u0435\u0440. \u0413\u043e\u0434\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u044b\u043b\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0442\u0447\u0435\u0442\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0426\u041f, \u0438 \u0432 PostgreSQL \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 9.6. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c 3 \u0433\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/parallelnye-zaprosy-v-postgresql","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T18:38:02+00:00","article:modified_time":"2019-10-31T18:38:02+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"30900","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-21 03:34:04","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 03:27:06","updated":"2026-01-21 03:34:04","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/30900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/comments?post=30900"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/30900\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media\/22879"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=30900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=30900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=30900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}