{"id":79039,"date":"2020-04-23T19:43:26","date_gmt":"2020-04-23T17:43:26","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/ekonomim-kopeechku-na-bolshih-obemah-v-postgresql"},"modified":"2020-04-23T19:43:26","modified_gmt":"2020-04-23T17:43:26","slug":"ekonomim-kopeechku-na-bolshih-obemah-v-postgresql","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/ekonomim-kopeechku-na-bolshih-obemah-v-postgresql","title":{"rendered":"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Duke vazhdojm\u00eb tem\u00ebn e regjistrimit t\u00eb flukseve t\u00eb m\u00ebdha t\u00eb t\u00eb dh\u00ebnave, e ngritur <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/497008\/\">n\u00eb artikullin e m\u00ebparsh\u00ebm mbi seksionimin<\/a><\/noindex>, n\u00eb k\u00ebt\u00eb do t\u00eb shqyrtojm\u00eb m\u00ebnyrat me t\u00eb cilat mund t\u00eb <b>ulet \"masa fizike\" e t\u00eb dh\u00ebnave t\u00eb ruajtura<\/b> n\u00eb PostgreSQL, dhe ndikimi i tyre n\u00eb performanc\u00ebn e serverit.<\/p>\n<p>B\u00ebhet fjal\u00eb p\u00ebr <b>konfigurimet TOAST dhe-alignimin e t\u00eb dh\u00ebnave<\/b>. \"N\u00eb mesatar\u00eb\" k\u00ebto metoda do t\u00eb kursejn\u00eb jo shum\u00eb burime, por \u2014 krejt\u00ebsisht pa modifikimin e Kodit t\u00eb aplikacionit.<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/4d43b9b43edb10c4c8f13159c7dd1eac.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nMegjithat\u00eb, p\u00ebrvoja jon\u00eb ka rezultuar mjaft produktive n\u00eb k\u00ebt\u00eb drejtim, pasi depozita e pothuajse \u00e7do monitorimi nga natyra e saj \u00ebsht\u00eb <b>pjes\u00ebrisht append-only<\/b> nga pik\u00ebpamja e t\u00eb dh\u00ebnave t\u00eb regjistruara. Dhe n\u00ebse ju intereson se si mund t\u00eb m\u00ebsoni baz\u00ebn p\u00ebr t\u00eb shkruar n\u00eb disk n\u00eb vend t\u00eb <b>200MB\/s<\/b> gjysm\u00eb m\u00eb pak \u2014 ju lutemi ndiqni m\u00eb posht\u00eb.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2>Sekretet e vogla t\u00eb t\u00eb dh\u00ebnave t\u00eb m\u00ebdha<\/h2>\n<p>\nN\u00eb p\u00ebrputhje me profilin e pun\u00ebs <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/487380\/\">t\u00eb sh\u00ebrbimit ton\u00eb<\/a><\/noindex>, ai rregullisht merr nga log-et <b>paketa teksti<\/b>.<\/p>\n<p>Dhe pasi <noindex><a rel=\"nofollow\" href=\"https:\/\/sbis.ru\/all_services\">kompleksi SBIS<\/a><\/noindex>, t\u00eb cilat Baza t\u00eb Dh\u00ebnash ne monitorojm\u00eb \u2014 \u00ebsht\u00eb nj\u00eb produkt me shum\u00eb komponente me struktura t\u00eb komplikuara t\u00eb t\u00eb dh\u00ebnave, at\u00ebher\u00eb edhe k\u00ebrkesat <b>p\u00ebr t\u00eb arritur performanc\u00ebn maksimale<\/b> po rezultojn\u00eb mjaft <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/486072\/\">\"multivolume\" me logjik\u00eb algoritmike t\u00eb komplikuar<\/a><\/noindex>. Pra, edhe volumi i \u00e7do instanc\u00eb t\u00eb ve\u00e7ant\u00eb t\u00eb k\u00ebrkes\u00ebs ose planit rezultues t\u00eb ekzekutimit n\u00eb log-un q\u00eb vjen tek ne \u00ebsht\u00eb \"n\u00eb mesatar\u00eb\" mjaft i madh.<\/p>\n<p>Le t\u00eb shohim struktur\u00ebn e nj\u00ebrit nga tabelat, n\u00eb t\u00eb cil\u00ebn ne shkruajm\u00eb t\u00eb dh\u00ebnat \"e pap\u00ebrpunuara\" \u2014 dometh\u00ebn\u00eb k\u00ebtu \u00ebsht\u00eb teksti origjinal nga regjistrimi i logut:<\/p>\n<pre><code class=\"sql\">CREATE TABLE rawdata_orig(\n  pack -- PK\n    uuid NOT NULL\n, recno -- PK\n    smallint NOT NULL\n, dt -- \u00e7el\u00ebsi i seksionit\n    date\n, data -- m\u00eb e r\u00ebnd\u00ebsishmja\n    text\n, PRIMARY KEY(pack, recno)\n);<\/code><\/pre>\n<p>\nNj\u00eb tabel\u00eb tipike e till\u00eb (e seksionuar pa dyshim, prandaj kjo \u00ebsht\u00eb nj\u00eb model seksioni), ku m\u00eb e r\u00ebnd\u00ebsishmja \u00ebsht\u00eb\u2014tekstin. Ndonj\u00ebher\u00eb mjaft voluminoze.<\/p>\n<p>Le t\u00eb kujtojm\u00eb se \"masa fizike\" e nj\u00eb regjistrimi n\u00eb PG nuk mund t\u00eb z\u00ebr\u00eb m\u00eb shum\u00eb se nj\u00eb faqe t\u00eb dh\u00ebnash, por \"masa logjike\" \u2014 \u00ebsht\u00eb nj\u00eb \u00e7\u00ebshtje krejt tjet\u00ebr. P\u00ebr t\u00eb shkruar nj\u00eb vler\u00eb voluminoze n\u00eb fush\u00eb (varchar\/text\/bytea) p\u00ebrdoret <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/storage-toast\">teknologjia TOAST<\/a><\/noindex>:<\/p>\n<blockquote><p>PostgreSQL p\u00ebrdor nj\u00eb madh\u00ebsi fiks t\u00eb faqes (zakonisht 8 KB) dhe nuk lejon q\u00eb tuple t\u00eb z\u00ebn\u00eb m\u00eb shum\u00eb se nj\u00eb faqe. Prandaj, nuk \u00ebsht\u00eb e mundur t\u00eb ruani direkt vlera shum\u00eb t\u00eb m\u00ebdha t\u00eb fushave. P\u00ebr t\u00eb tejkaluar k\u00ebt\u00eb kufizim, vlerat e m\u00ebdha t\u00eb fushave kompresohen dhe\/ose ndahen n\u00eb disa rreshta fizik\u00eb. Kjo ndodh pa u v\u00ebn\u00eb re nga p\u00ebrdoruesi dhe ndikon n\u00eb shumic\u00ebn e kodit t\u00eb serverit n\u00eb m\u00ebnyr\u00eb t\u00eb par\u00ebnd\u00ebsishme. K\u00ebta metoda njihet si TOAST \u2026<\/p><\/blockquote>\n<p>\nN\u00eb fakt, p\u00ebr \u00e7do tabel\u00eb me \u00abfusha potencialisht t\u00eb m\u00ebdha\u00bb automatikisht <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/storage-toast#STORAGE-TOAST-ONDISK\">krijohet nj\u00eb tabel\u00eb p\u00ebrkat\u00ebse me \u00abcop\u00ebza\u00bb<\/a><\/noindex> t\u00eb \u00e7do regjistrimi \u00abt\u00eb madh\u00bb me segmente prej 2KB:<\/p>\n<pre><code class=\"sql\">TOAST(\n  chunk_id\n    integer\n, chunk_seq\n    integer\n, chunk_data\n    bytea\n, PRIMARY KEY(chunk_id, chunk_seq)\n);<\/code><\/pre>\n<p>\nDometh\u00ebn\u00eb, n\u00ebse na duhet t\u00eb shkruajm\u00eb nj\u00eb rresht me nj\u00eb vler\u00eb \u00abt\u00eb madhe\u00bb <code>data<\/code>, regjistrimi real do t\u00eb ndodhi <b>jo vet\u00ebm n\u00eb tabel\u00ebn kryesore dhe PK-n\u00eb e saj, por edhe n\u00eb TOAST dhe PK-n\u00eb e tij<\/b>.<\/p>\n<h4>T\u00eb zvog\u00eblojm\u00eb ndikimin e TOAST<\/h4>\n<p>\nPor shumica e regjistrimeve tona nuk jan\u00eb kaq t\u00eb m\u00ebdha, <b>n\u00eb 8KB duhet t\u00eb p\u00ebrfshihen<\/b> \u2014 si mund ta kursejm\u00eb k\u00ebt\u00eb?..<\/p>\n<p>K\u00ebtu vjen n\u00eb ndihm\u00eb atributi <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/storage-toast#STORAGE-TOAST-ONDISK\"><code>STORAGE<\/code><\/a><\/noindex> i kolon\u00ebs s\u00eb tabel\u00ebs:<\/p>\n<blockquote>\n<ul>\n<li><b>EXTENDED<\/b> lejon si kompresimin ashtu edhe ruajtjen e ve\u00e7ant\u00eb. Ky \u00ebsht\u00eb <b>opsioni standard<\/b> p\u00ebr shumic\u00ebn e llojeve t\u00eb t\u00eb dh\u00ebnave q\u00eb jan\u00eb t\u00eb p\u00ebrputhshme me TOAST. Fillimisht b\u00ebhet nj\u00eb p\u00ebrpjekje p\u00ebr t\u00eb realizuar kompresimin, pastaj \u2014 ruajtja jasht\u00eb tabel\u00ebs, n\u00ebse rreshti \u00ebsht\u00eb ende shum\u00eb i madh.<\/li>\n<li><b>MAIN<\/b> lejon kompresimin, por jo ruajtjen e ve\u00e7ant\u00eb. (N\u00eb t\u00eb v\u00ebrtet\u00eb, ruajtja e ve\u00e7ant\u00eb do t\u00eb kryhet p\u00ebr k\u00ebto kolona, por vet\u00ebm <b>si nj\u00eb mas\u00eb ekstreme<\/b>, kur nuk ka m\u00ebnyr\u00eb tjet\u00ebr p\u00ebr t\u00eb zvog\u00ebluar rreshtin n\u00eb m\u00ebnyr\u00eb q\u00eb t\u00eb p\u00ebrfshihej n\u00eb faqe.)<\/li>\n<\/ul>\n<\/blockquote>\n<p>N\u00eb t\u00eb v\u00ebrtet\u00eb, kjo \u00ebsht\u00eb pik\u00ebrisht ajo q\u00eb na nevojitet p\u00ebr tekstin \u2014 <b>t\u00eb kompresojm\u00eb sa m\u00eb shum\u00eb t\u00eb jet\u00eb e mundur dhe n\u00ebse nuk \u00ebsht\u00eb e mundur \u2014 ta transferojm\u00eb n\u00eb TOAST<\/b>. Kjo mund t\u00eb b\u00ebhet direkt \"n\u00eb flak\u00eb\", me nj\u00eb komand\u00eb:<\/p>\n<pre><code class=\"sql\">ALTER TABLE rawdata_orig ALTER COLUMN data SET STORAGE MAIN;<\/code><\/pre>\n<p><\/p>\n<h4>Si t\u00eb vler\u00ebsojm\u00eb efektin<\/h4>\n<p>\nDuke qen\u00eb se \u00e7do dit\u00eb fluksi i t\u00eb dh\u00ebnave ndryshon, nuk mund t\u00eb krahasojm\u00eb numrat absolut\u00eb, por n\u00eb relative, sa <b>m\u00eb pak pjes\u00eb<\/b> e kemi shkruar n\u00eb TOAST \u2014 aq m\u00eb mir\u00eb. Por k\u00ebtu ka nj\u00eb rrezik \u2014 sa m\u00eb shum\u00eb t\u00eb jet\u00eb \"sasia fizike\" e \u00e7do regjistrimi t\u00eb ve\u00e7ant\u00eb, aq m\u00eb \"e gjer\u00eb\" b\u00ebhet indeksi, sepse duhet t\u00eb mbuloj\u00eb m\u00eb shum\u00eb faqe t\u00eb dh\u00ebnash.<\/p>\n<p>Seksioni <b>para ndryshimeve<\/b>:<\/p>\n<pre><code class=\"plaintext\">heap  = 37GB (39%)\nTOAST = 54GB (57%)\nPK    =  4GB ( 4%)\n<\/code><\/pre>\n<p>\nSeksioni <b>pas ndryshimeve<\/b>:<\/p>\n<pre><code class=\"plaintext\">heap  = 37GB (67%)\nTOAST = 16GB (29%)\nPK    =  2GB ( 4%)<\/code><\/pre>\n<p>\nN\u00eb t\u00eb v\u00ebrtet\u00eb, ne <b>filluam t\u00eb shkruajm\u00eb n\u00eb TOAST dy her\u00eb m\u00eb rrall\u00eb<\/b>, e cila jo jo diskun, por po CPU:<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/547485eff9c6491ffe4d59e5c81f656d.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/6bd3b18146c20959693f961e41fff447.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nDua t\u00eb theksoj se tani ne po \"lexojm\u00eb\" dhe diskun m\u00eb pak, jo vet\u00ebm \"shkruajm\u00eb\" - sepse kur shtojm\u00eb nj\u00eb sh\u00ebnim n\u00eb ndonj\u00eb tabel\u00eb, na nevojitet \"leximi\" gjithashtu i nj\u00eb pjese t\u00eb pem\u00ebs p\u00ebr \u00e7do indeks p\u00ebr t\u00eb p\u00ebrcaktuar pozicionin e saj t\u00eb ardhsh\u00ebm n\u00eb to.<\/p>\n<h2>Kujt i p\u00ebrshtatet PostgreSQL 11<\/h2>\n<p>\nPas p\u00ebrdit\u00ebsimit n\u00eb PG11 vendos\u00ebm t\u00eb vazhdojm\u00eb \"tuning\" TOAST dhe v\u00ebmend\u00ebm se q\u00eb nga kjo version u b\u00eb i disponuesh\u00ebm p\u00ebr konfigurimin e parametrave <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/11\/storage-toast#STORAGE-TOAST-ONDISK\"><code>toast_tuple_target<\/code><\/a><\/noindex>:<\/p>\n<blockquote><p>Kodi i p\u00ebrpunimit TOAST aktiveohet vet\u00ebm kur vlera e rreshtit q\u00eb duhet t\u00eb ruhet n\u00eb tabel\u00eb \u00ebsht\u00eb m\u00eb e madhe se TOAST_TUPLE_THRESHOLD bajt (zakonisht 2 KB). Kodi TOAST do t\u00eb kompresoj\u00eb dhe\/ose do t\u00eb transferoj\u00eb vlerat e fush\u00ebs jasht\u00eb tabel\u00ebs derisa vlera e rreshtit t\u00eb b\u00ebhet m\u00eb e vog\u00ebl se TOAST_TUPLE_TARGET bajt (vler\u00eb q\u00eb ndryshon, gjithashtu zakonisht 2 KB) ose do t\u00eb jet\u00eb e pamundur t\u00eb zvog\u00eblohet.<\/p><\/blockquote>\n<p>Ne vendos\u00ebm q\u00eb t\u00eb dh\u00ebnat tona zakonisht jan\u00eb ose \"n\u00eb t\u00eb v\u00ebrtet\u00eb t\u00eb shkurtra\" ose menj\u00ebher\u00eb \"t\u00eb gjata\", prandaj vendos\u00ebm t\u00eb kufizohemi n\u00eb vler\u00ebn m\u00eb minimale t\u00eb mundshme:<\/p>\n<pre><code class=\"sql\">ALTER TABLE rawplan_orig SET (toast_tuple_target = 128);<\/code><\/pre>\n<p>\nLe t\u00eb shohim se si ndikuan konfigurimet e reja n\u00eb ngarkes\u00ebn e diskut pas riparimit:<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/ccaa4879e413a566b362d01582eb8c19.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nMjaft mir\u00eb! Mesatarja <b>e radh\u00ebs ndaj diskut u reduktua<\/b> p\u00ebraf\u00ebrsisht 1.5 her\u00eb, dhe \"z\u00ebnia\" e diskut - rreth 20%! Por ndoshta, ndonj\u00ebher\u00eb ka pasur ndikim n\u00eb CPU?<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/f7026e5809853d35c6fb7a8376b9f369.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nT\u00eb pakt\u00ebn, nuk ka p\u00ebrmir\u00ebsuar p\u00ebr keq. Megjithat\u00eb, \u00ebsht\u00eb e v\u00ebshtir\u00eb t\u00eb gjykohet, p\u00ebr shkak se k\u00ebshtu volumet nuk mund t\u00eb ngjallin mesataren e ngarkes\u00ebs s\u00eb CPU mbi <b>5%<\/b>.<\/p>\n<h2>Ndryshimi i rendit t\u00eb shuma\u2026 ndryshon!<\/h2>\n<p>\nSi\u00e7 dihet, nj\u00eb qindark\u00eb ruan nj\u00eb rubel, dhe me volumet tona t\u00eb ruajtjes p\u00ebr rreth <b>10TB\/muaj<\/b> madje edhe nj\u00eb optimizim i vog\u00ebl mund t\u00eb sillte nj\u00eb profit t\u00eb mir\u00eb. Prandaj, ne e kemi p\u00ebrqendruar v\u00ebmendjen ton\u00eb n\u00eb struktur\u00ebn fizike t\u00eb t\u00eb dh\u00ebnave tona - konkretisht <b>\"mbushja\" e fushave brenda sh\u00ebnimit<\/b> t\u00eb \u00e7do tabele.<\/p>\n<p>Sepse p\u00ebr shkak t\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/postgrespro\/blog\/444536\/\">rrjeshtimit t\u00eb t\u00eb dh\u00ebnave<\/a><\/noindex> kjo drejtp\u00ebrdrejt <noindex><a rel=\"nofollow\" href=\"https:\/\/docs.gitlab.com\/ee\/development\/ordering_table_columns.html\">ndikon n\u00eb volumet e fundit<\/a><\/noindex>:<\/p>\n<blockquote><p>Shum\u00eb arkitektura parashikojn\u00eb rreshtimin e t\u00eb dh\u00ebnave sipas kufijve t\u00eb fjal\u00ebve makinerike. P\u00ebr shembull, n\u00eb nj\u00eb sistem 32-bit x86 numerat e plot\u00eb (tipi integer, z\u00eb 4 bajt) do t\u00eb rreshtohen n\u00eb kufirin e fjal\u00ebve 4-bajt\u00ebshe, ashtu si numrat me pik\u00eb t\u00eb dyfisht\u00eb (tipi double precision, 8 bajt). Nd\u00ebrsa n\u00eb nj\u00eb sistem 64-bit, vlerat double do t\u00eb rreshtohen n\u00eb kufirin e fjal\u00ebve 8-bajt\u00ebshe. Kjo \u00ebsht\u00eb nj\u00eb tjet\u00ebr arsye p\u00ebr moskompatibilitet.<\/p>\n<p>P\u00ebr shkak t\u00eb rregullimit, madh\u00ebsia e rreshtit t\u00eb tabel\u00ebs varet nga rendi i vendosjes s\u00eb fushave. N\u00eb p\u00ebrgjith\u00ebsi, ky efekt nuk \u00ebsht\u00eb shum\u00eb i duksh\u00ebm, por n\u00eb disa raste ai mund t\u00eb \u00e7oj\u00eb n\u00eb nj\u00eb rritje t\u00eb konsiderueshme t\u00eb madh\u00ebsis\u00eb. P\u00ebr shembull, n\u00ebse fusha t\u00eb tipit char(1) dhe integer vendosen ndaras, zakonisht do t\u00eb humbin 3 byte m\u00eb kot.<\/p><\/blockquote>\n<p>\nLe t\u00eb fillojm\u00eb me modele sintetike:<\/p>\n<pre><code class=\"sql\">SELECT pg_column_size(ROW(\n  '0000-0000-0000-0000-0000-0000-0000-0000'::uuid\n, 0::smallint\n, '2019-01-01'::date\n));\n-- 48 byte\n\nSELECT pg_column_size(ROW(\n  '2019-01-01'::date\n, '0000-0000-0000-0000-0000-0000-0000-0000'::uuid\n, 0::smallint\n));\n-- 46 byte<\/code><\/pre>\n<p>\nNga ku erdh\u00ebn disa byte t\u00eb tepruar n\u00eb rastin e par\u00eb? E thjesht\u00eb \u2014 <b>smallint me 2 byte rregullohet n\u00eb kufirin me 4 byte<\/b> para fush\u00ebs tjet\u00ebr, nd\u00ebrsa kur \u00ebsht\u00eb e fundit \u2014 nuk ka nevoj\u00eb p\u00ebr rregullim.<\/p>\n<p>N\u00eb teori \u2014 gjith\u00e7ka \u00ebsht\u00eb mir\u00eb dhe fushat mund t\u00eb riorganizohen si\u00e7 d\u00ebshirohen. Le t\u00eb kontrollojm\u00eb me t\u00eb dh\u00ebna reale p\u00ebr shembullin e nj\u00eb nga tabelave, sekzioni ditor t\u00eb cilit i nevojiten 10-15GB.<\/p>\n<p>Struktura fillestare:<\/p>\n<pre><code class=\"sql\">CREATE TABLE public.plan_20190220\n(\n-- Trash\u00ebguar nga tabela plan:  pack uuid NOT NULL,\n-- Trash\u00ebguar nga tabela plan:  recno smallint NOT NULL,\n-- Trash\u00ebguar nga tabela plan:  host uuid,\n-- Trash\u00ebguar nga tabela plan:  ts timestamp with time zone,\n-- Trash\u00ebguar nga tabela plan:  exectime numeric(32,3),\n-- Trash\u00ebguar nga tabela plan:  duration numeric(32,3),\n-- Trash\u00ebguar nga tabela plan:  bufint bigint,\n-- Trash\u00ebguar nga tabela plan:  bufmem bigint,\n-- Trash\u00ebguar nga tabela plan:  bufdsk bigint,\n-- Trash\u00ebguar nga tabela plan:  apn uuid,\n-- Trash\u00ebguar nga tabela plan:  ptr uuid,\n-- Trash\u00ebguar nga tabela plan:  dt date,\n  CONSTRAINT plan_20190220_pkey PRIMARY KEY (pack, recno),\n  CONSTRAINT chck_ptr CHECK (ptr IS NOT NULL),\n  CONSTRAINT plan_20190220_dt_check CHECK (dt = '2019-02-20'::date)\n)\nINHERITS (public.plan)<\/code><\/pre>\n<p>\nSekcioni pas nd\u00ebrrimit t\u00eb rendit t\u00eb kolonave \u2014 sakt\u00ebsisht <b>t\u00eb nj\u00ebjtat fusha, vet\u00ebm rendi tjet\u00ebr<\/b>:<\/p>\n<pre><code class=\"sql\">CREATE TABLE public.plan_20190221\n(\n-- Trash\u00ebguar nga tabela plan:  dt date NOT NULL,\n-- Trash\u00ebguar nga tabela plan:  ts timestamp with time zone,\n-- Trash\u00ebguar nga tabela plan:  pack uuid NOT NULL,\n-- Trash\u00ebguar nga tabela plan:  recno smallint NOT NULL,\n-- Trash\u00ebguar nga tabela plan:  host uuid,\n-- Trash\u00ebguar nga tabela plan:  apn uuid,\n-- Trash\u00ebguar nga tabela plan:  ptr uuid,\n-- Trash\u00ebguar nga tabela plan:  bufint bigint,\n-- Trash\u00ebguar nga tabela plan:  bufmem bigint,\n-- Trash\u00ebguar nga tabela plan:  bufdsk bigint,\n-- Trash\u00ebguar nga tabela plan:  exectime numeric(32,3),\n-- Trash\u00ebguar nga tabela plan:  duration numeric(32,3),\n  CONSTRAINT plan_20190221_pkey PRIMARY KEY (pack, recno),\n  CONSTRAINT chck_ptr CHECK (ptr IS NOT NULL),\n  CONSTRAINT plan_20190221_dt_check CHECK (dt = '2019-02-21'::date)\n)\nINHERITS (public.plan)<\/code><\/pre>\n<p>\nV\u00ebllimi total i sekcionit p\u00ebrcaktohet nga numri i \"fakteve\" dhe varet vet\u00ebm nga proceset e jashtme, prandaj le t\u00eb ndajm\u00eb madh\u00ebsin\u00eb e heap (<code>pg_relation_size<\/code>) p\u00ebr numrin e sh\u00ebnimeve n\u00eb t\u00eb \u2014 pra do t\u00eb marrim <b>p\u00ebrmas\u00ebn mesatare t\u00eb sh\u00ebnimit t\u00eb ruajtur real<\/b>:<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/06be2d7d70d223e7678f9a478e4c293f.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<b>Minus 6% t\u00eb volumit<\/b>, shk\u00eblqyer!<\/p>\n<p>Por, natyrisht, gj\u00ebrat nuk jan\u00eb aq roz\u00eb \u2014 sepse <b>n\u00eb indekset nuk mund t\u00eb ndryshojm\u00eb rendin e fushave<\/b>, dhe prandaj \u00abn\u00eb p\u00ebrgjith\u00ebsi\u00bb (<code>pg_total_relation_size<\/code>)\u2026<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/8beff38e5034fc0d40665b75cb3b3625.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n\u2026 megjithat\u00eb, edhe k\u00ebtu <b>kemi kursyer 1.5%<\/b>, pa ndryshuar asnj\u00eb rresht kodi. Po, v\u00ebrtet!<\/p>\n<p><img decoding=\"async\" alt=\"Kurseni qindarka n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL\" src=\"\/wp-content\/uploads\/2020\/04\/10f4a2151465a38bf45823a5d360302b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p>Dua t\u00eb theksoj se varianti i dh\u00ebn\u00eb m\u00eb lart i renditjes s\u00eb fushave \u2014 nuk \u00ebsht\u00eb fakt se \u00ebsht\u00eb m\u00eb optimal. Sepse disa blloqe fushash nuk dua t'i \u00ab\u00e7aj\u00bb p\u00ebr arsye estetike \u2014 p\u00ebr shembull, nj\u00eb \u00e7ift <code>(pack, recno)<\/code>, i cili \u00ebsht\u00eb PK p\u00ebr k\u00ebt\u00eb tabel\u00eb.<\/p>\n<p>N\u00eb t\u00ebr\u00ebsi, p\u00ebrcaktimi i \u00abrenditjes minimale\u00bb t\u00eb fushave \u2014 \u00ebsht\u00eb nj\u00eb detyr\u00eb mjaft e thjesht\u00eb \u00abk\u00ebrkuese\u00bb. Prandaj ju mund t\u00eb merrni rezultate even m\u00eb t\u00eb mira me t\u00eb dh\u00ebnat tuaja se sa ne \u2014 provoni!<br \/>\n<br \/>Burimi: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/498292\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0442\u0435\u043c\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u043d\u044f\u0442\u0443\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u043f\u0440\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u044d\u0442\u043e\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u00ab\u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439\u00bb \u0440\u0430\u0437\u043c\u0435\u0440 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0433\u043e \u0432 PostgreSQL, \u0438 \u0438\u0445 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 TOAST \u0438 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u00ab\u0412 \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u00bb \u044d\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0437\u0430\u0442\u043e \u2014 \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u0434\u043d\u0430\u043a\u043e, [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":79040,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-79039","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.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0442\u0435\u043c\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u043d\u044f\u0442\u0443\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u043f\u0440\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u044d\u0442\u043e\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e.\" \/>\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\/ekonomim-kopeechku-na-bolshih-obemah-v-postgresql\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\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\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u043c \u043a\u043e\u043f\u0435\u0435\u0447\u043a\u0443 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0432 PostgreSQL | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0442\u0435\u043c\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u043d\u044f\u0442\u0443\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u043f\u0440\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u044d\u0442\u043e\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/ekonomim-kopeechku-na-bolshih-obemah-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=\"2020-04-23T17:43:26+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-04-23T17:43:26+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\udd47Kurseni disa penny n\u00eb v\u00ebllime t\u00eb m\u00ebdha n\u00eb PostgreSQL | ProHoster","description":"Duke vazhduar tem\u00ebn e regjistrimit t\u00eb flukseve t\u00eb m\u00ebdha t\u00eb t\u00eb dh\u00ebnave, e ngritur n\u00eb artikullin e m\u00ebparsh\u00ebm mbi ndarjen e tabelave, n\u00eb k\u00ebt\u00eb do t\u00eb shqyrtojm\u00eb m\u00ebnyrat se si mund t\u00eb","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/ekonomim-kopeechku-na-bolshih-obemah-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\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u043c \u043a\u043e\u043f\u0435\u0435\u0447\u043a\u0443 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0432 PostgreSQL | ProHoster","og:description":"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0442\u0435\u043c\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u043d\u044f\u0442\u0443\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u043f\u0440\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u044d\u0442\u043e\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e.","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/ekonomim-kopeechku-na-bolshih-obemah-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":"2020-04-23T17:43:26+00:00","article:modified_time":"2020-04-23T17:43:26+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"79039","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":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 16:46:33","updated":"2022-09-28 06:02:32","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\/79039","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=79039"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/79039\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media\/79040"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=79039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=79039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=79039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}