Posts

Showing posts with the label Partition

PostgreSQL 11 Yenilikleri 3 - Partition Yenilikleri

Image
Merhaba, PostgreSQL 11’de partition’un nasıl yapıldığından bahsetmeden önce Partitioning nedir ve PostgreSQL 10 ve öncesinde nasıl yapıldığından bahsetmek isterim. Verilerin belirlenen kriterlerde farklı tablolara ayrıştırılmasına Partitioning denir. PostgreSQL’de partitioned tabloları bireysel tabloların oluşturduğu partition tablolarından meydana gelir. Bu tablolar tek bir tablo altında gruplandırılırlar. 10GB tablonuz olsun. Tüm tablodan veri çekmek yerine daha küçük boyuttaki partition tablolarından veri çekmek daha hızlı olacaktır. Eğer sorgunuzun yapısı partition yapınıza uygunsa arayacağı kriterin olduğu partition tablosuna gidecektir. Örneğin tarihlere göre aylık olarak tablonuzu böldüyseniz, sorgunuzda partition key değeriniz yoksa işe yaramayacaktır. Önemli noktalardan biri partition key’inin kullanılmasıdır. PostgreSQL 9.6 ve öncesinde partition yapısını kurmak için partitioned tabloya eklenecek verilerin partition tablolarına eklenmesi için trigger oluşturuyorduk. Tüm kr

How To Partitioning on PostgreSQL 9.6

Hello, I'm gonna share my experience on partitioning and show how affect partition on scripts. I'm gonna show you how to partitioning on existing table. Let's begin to following steps; Create new table. It's gonna be partitioned table. Create partition tables. Grant privileges to partition tables and partitioned table. Generate function and trigger on partitioned table. Insert data from main table to partitioned table. Create indexes if you had on main table on partition tables. Check partition tables everything is fine. Rename main table. Rename partitioned table name like main table Drop old main table. Not that: if you have some indexes or constraint on your main table, not to increase inserting time you should create your new main table and other partition tables without constraints and indexes. After insert whole data to partition tables you can add indexes and constraints. It will be help you to executing insert statement more quickly.  Bef