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') ;