From: | Alejandro Carrillo <fasterzip(at)yahoo(dot)es> |
---|---|
To: | "pgsql-es-ayuda(at)postgresql(dot)org" <pgsql-es-ayuda(at)postgresql(dot)org> |
Cc: | "jaime(at)2ndquadrant(dot)com" <jaime(at)2ndquadrant(dot)com>, "alvherre(at)alvh(dot)no-ip(dot)org" <alvherre(at)alvh(dot)no-ip(dot)org> |
Subject: | Cual es mas rapida |
Date: | 2012-01-03 18:55:13 |
Message-ID: | 1325616913.15807.YahooMailNeo@web27405.mail.ukl.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Buenas tardes,
¿Cual de estas 2 consultas, para hallar el maximo registro de una tabla, es más rápida?
Gracias,
Alejandro
/*script de tabla*/
CREATE TABLE det_eventos
(
act_codigo integer,
consecutivo numeric(18,0) NOT NULL,
fecha timestamp with time zone,
numsol character varying(20),
numdetsol character varying(20),
novedad character varying(1),
fechanov timestamp without time zone,
usuario character varying(20),
CONSTRAINT pk_deteventos PRIMARY KEY (consecutivo )
)
WITH (
OIDS=FALSE
);
ALTER TABLE det_eventos
OWNER TO postgres;
GRANT ALL ON TABLE det_eventos TO postgres;
GRANT INSERT ON TABLE det_eventos TO public;
-- Index: ind_actcodigo
CREATE INDEX ind_actcodigo
ON det_eventos
USING btree
(act_codigo NULLS FIRST);
/* sql's a comparar*/
select f_campos_variables(t.campo14,t.campo15, 'P_NOMBRE')
from
(select * from det_eventos de
where de.numsol= '12584980'
order by consecutivo desc ) t
limit 1
;
--nombre del subscriptor
select f_campos_variables(de.campo14,de.campo15, 'P_NOMBRE')
from det_eventos de where de.consecutivo=
(select max(consecutivo) from det_eventos
where numsol= '12584980')
;
From | Date | Subject | |
---|---|---|---|
Next Message | Eduardo Morras | 2012-01-03 19:13:08 | Re: Cual es mas rapida |
Previous Message | Edwin Quijada | 2012-01-02 16:53:56 | RE: Duda sobre replicacion Streaming |