Re: Bulk Update

From: Erkan Durmuş <derkan(at)gmail(dot)com>
To: pgsql-tr-genel(at)postgresql(dot)org
Subject: Re: Bulk Update
Date: 2017-09-30 07:39:28
Message-ID: 54f75219-d54c-ecf3-6410-80954b068c91@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-tr-genel

Eğer |COMMIT|etmez iseniz ORACLE'da |ORA-1562 FAILED TO EXTEND ROLLBACK
SEGMENT|hatası alırsınız. Fakat PostgreSQL'in işleyişi biraz farklı,
rollback segment yok, o yüzden de extend edilmesi gereken birproblem de
olmuyor (Onun yerine |VACUUM|işlemlerimiz kalıyor sonrası için :-)).
Şunu okuyunuz:

It is interesting how the dynamic allocation of disk space is used
for the storage and processing of records within tables. The files
that represent the table grow as the table grows. It also grows with
transactions that are performed against it. In Oracle there is a
concept of rollback or undo segments that hold the information for
rolling back a transaction. In PostgreSQL the data is stored within
the file that represents the table. So when deletes and updates are
performed on a table, the file that represents the object will
contain the previous data. This space gets reused but to force
recovery of used space, a maintenance process called /vacuum/must be
executed.

Onun için bulk update'i tek SQL ile yapabilirsiniz. Ama yine de
|COMMIT|'i transaction içinde yapmanız gerekiyorsa, cursor'u |WITH
HOLD|ile tanımlayınız
</docs/current/static/sql-declare.html>.

|WITH HOLD|specifies that the cursor can continue to be used after
the transaction that created it successfully commits. |WITHOUT
HOLD|specifies that the cursor cannot be used outside of the
transaction that created it. If neither |WITHOUT HOLD|nor |WITH
HOLD|is specified, |WITHOUT HOLD|is the default.

On 29-09-2017 10:03, Fırat Güleç wrote:
>
> Merhabalar,
>
> Bir konuda yardımınız ihtiyacım var. Postgresql 9.5.8 versiyonunu
> kullanıyoruz. Bulk bir update yapmaya ihtiyacımız oldu, yaklaşık 4.5
> milyonluk bir kayıt. Oracle’da begin end’in arasına commit
> koyabiliyorduk. Fakat Postgresql’de bunu yapamadığımızı farkına
> vardık. 100 kayıt update ettikten sonra commit yapmak istiyoruz. Bu
> gibi ihtiyaçlar için Postgresql’de nasıl bir çözüm kullanıyorsunuz?
>
> İyi çalışmalar.
>
> Örnek kod:
>
> *DECLARE
> **c_delivery **RECORD**;
>     cur_rad CURSOR (**x_address_id **BIGINT**, **x_receiver_id
> **BIGINT**) FOR SELECT */*/*
>                         FROM **receiver_address**
>                                                                   
> WHERE **receiver_id**= **x_receiver_id**AND
> **address_id**= **x_address_id**;
> **c_rad **RECORD**;
> BEGIN
>   FOR **c_delivery**IN SELECT */*/*FROM **delivery**WHERE
> recipient_address_id is NULL LIMIT **p_record_cnt**LOOP
>
>     OPEN
> cur_rad(**c_delivery**.**receiver_address_id**,**c_delivery**.**receiver_id**);
>     FETCH cur_rad INTO **c_rad**;
>     IF **c_rad**.id IS NOT NULL
>     THEN
>       UPDATE ***********SET recipient_address_id = **c_rad**.id WHERE
> **id**= **c_delivery**.**id**;
>       UPDATE ****************SET recipient_address_id = **c_rad**.id
> WHERE **delivery_id**= **c_delivery**.**id**;
>     END IF;
>     CLOSE cur_rad;
>   END LOOP;
> END;*
>
> *FIRAT GÜLEÇ***
> Veritabanı Yöneticisi
> firat(dot)gulec(at)hepsiexpress(dot)com <mailto:firat(dot)gulec(at)hepsiexpress(dot)com>
>
> *M:*0 532 210 57 18
> İnönü Mh. Mimar Sinan Cd. No:3 Güzeller Org.San.Bölg. GEBZE / KOCAELİ
>
> ------------------------------------------------------------------------
>
> Inline image 1
>

In response to

  • Bulk Update at 2017-09-29 07:03:02 from Fırat Güleç

Responses

Browse pgsql-tr-genel by date

  From Date Subject
Next Message Fırat Güleç 2017-09-30 12:31:57 Re: Bulk Update
Previous Message N. Can KIRIK 2017-09-29 21:25:49 Re: Bulk Update