Re: Valor del parametro max_locks_per_transaction

From: Sergio Sinuco <sergiosinuco(at)datatraffic(dot)com(dot)co>
To: Ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Valor del parametro max_locks_per_transaction
Date: 2016-08-02 19:22:51
Message-ID: CAHn1vgFNw8ZDqqDKUKE+ddsjnwbZvQXJRjseUUoJ+H5H5OKZ6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola.

Este es el valor actual de los parametros que me mencionaron. Basicamente
estan los valores por defecto.

constraint_exclusion = partition
max_locks_per_transaction = 64
max_connections = 100
max_prepared_transactions = 0

Tenemos 4 tablas padre. Cada una de ellas con mas o menos 200 hijas. Creo
que podríamos reducir las hijas a 50.

La definicion de una tabla padre es:

CREATE TABLE parseo.trama_1

(

id bigint NOT NULL DEFAULT nextval('parseo.trama_id_seq'::regclass),

texto character varying,

fecha timestamp without time zone NOT NULL DEFAULT now(),
ejecutada boolean DEFAULT true,

CONSTRAINT trama_1_pkey3 PRIMARY KEY (id)

)

WITH (

OIDS=FALSE

);

Hacemos una particion por numero de la semana:

CREATE TABLE parseo.trama_10_2012

(

-- Inherited from table parseo.trama_1: id bigint NOT NULL DEFAULT
nextval('parseo.trama_id_seq'::regclass),

-- Inherited from table parseo.trama_1: texto character varying,

-- Inherited from table parseo.trama_1: fecha timestamp without time zone
NOT NULL DEFAULT now(),
-- Inherited from table parseo.trama_1: ejecutada boolean DEFAULT true,

CONSTRAINT pk_trama_10_2012 PRIMARY KEY (id),

CONSTRAINT trama_10_2012_fecha_check CHECK (fecha >= '2012-03-04
00:00:00'::timestamp without time zone AND fecha < '2012-03-11
00:00:00'::timestamp without time zone)

)

INHERITS (parseo.trama_1)

WITH (

OIDS=FALSE

);

El trigger que tenemos calcula el numero de la semana del año del registro
y lo inserta en la tabla correspondiente

CREATE OR REPLACE FUNCTION parseo.ins_trama()

RETURNS trigger AS

$BODY$

DECLARE

i integer;

anovar integer;

BEGIN

anovar = EXTRACT(YEAR FROM NEW.fecha);

i = ceil(extract(doy from NEW.fecha)/7);

--Insertar el registro en la tabla correspondiente

PERFORM 1 FROM pg_tables WHERE tablename = 'trama_'||i||'_'||anovar;

IF(FOUND) THEN

EXECUTE 'INSERT INTO '||'parseo.trama_'||i||'_'||anovar

|| ' SELECT ($1).*'

USING NEW;

ELSE

RAISE EXCEPTION 'No existe la tabla para esta semana y anio trama_%_% en
fecha %',i,anovar,NEW.fecha;

END IF;

RETURN NULL;

END;

$BODY$

LANGUAGE plpgsql VOLATILE

COST 100;

Lo que si estoy viendo es que despues de insertar el registro se hace
actualiza en la tabla padre usando la llave primaria.

UPDATE parseo.trama_1 SET ejecutada=true WHERE id=idtramain;

Supongo que esta actualizacion es la que hace que se haga lock en todas las
llaves primarias de las hijas. Alguien me podria aclarar como funciona esta
actualizacion? Intentaria actualizar el registro en todas las hijas?

El 2 de agosto de 2016, 12:59, Jaime Casanova <
jaime(dot)casanova(at)2ndquadrant(dot)com> escribió:

> 2016-08-02 10:22 GMT-05:00 Sergio Sinuco <sergiosinuco(at)datatraffic(dot)com(dot)co
> >:
> > Hola a todos.
> >
> > En la base de datos que tenemos en produccion tenemos el siguiente error
> en
> > el log
> >
> > 2016-08-01 14:26:34 COT 30621 ERROR: out of shared memory
> > 2016-08-01 14:26:34 COT 30621 HINT: You might need to increase
> > max_locks_per_transaction.
> >
>
> Que valores tienes definidos en:
>
> max_locks_per_transaction
> max_connections
> max_prepared_transactions
>
> Cuantas hijas tiene la tabla particionada?
> Puedes mostrar la definición de alguna de las hijas?
>
> y si, si subes max_locks_per_transaction a 600 puedes bloquear hasta
> 600 objetos distintos por transacción (considera las tablas hijas,
> indices, tablas toast, indices de las tablas toast, secuencias?,
> catalogos y sus repectivos objetos dependientes y asi)
>
> --
> Jaime Casanova www.2ndQuadrant.com
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

--
Sergio E. Sinuco Leon
Arquitecto de desarrollo
Datatraffic S.A.S.
Móvil: (57) 310 884 26 50
Fijo (+571) 7426160 Ext 115
Carrera 47 A No 91 - 91
Bogotá, Colombia.
www.datatraffic.com.co

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2016-08-02 20:44:29 Re: Valor del parametro max_locks_per_transaction
Previous Message Jaime Casanova 2016-08-02 17:59:25 Re: Valor del parametro max_locks_per_transaction