Re: avoid lock conflict between SELECT and TRUNCATE

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Sridhar N Bamandlapally <sridhar(dot)bn1(at)gmail(dot)com>, Venkata Balaji N <nag1010(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: avoid lock conflict between SELECT and TRUNCATE
Date: 2015-09-15 07:04:05
Message-ID: 55F7C2E5.1060304@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/11/15 4:50 AM, Sridhar N Bamandlapally wrote:
> 1) creating temporary table (say temp_users) on table users with
> required data/columns-list and index on column user_id,
> ...this will be faster as there will be no joins with other tables
>
> 2) also need index on table auths_with_trans column user_id
>
> 3) replacing users with temp_users in BEGIN block

That's not really going to help unless the slow part is that you're
using a cursor (which is why I don't like them...)

FWIW, now that there's better transactional visibility support in the
catalogs it might be possible to reduce the lock contention of trunkcate.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Johann Spies 2015-09-15 07:14:02 Materialized View or table?
Previous Message Biswadeep Banerjee 2015-09-15 06:33:27 Re: [BUGS] BUG #13619: regression functions return Null