Re: Uso de un index especifico

From: "Guillermo Garcia A(dot)" <ggarcia(at)chiclayo(dot)abaco-corp(dot)edu(dot)pe>
To: "'Alvaro Herrera'" <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: "'lista de PostgreSql-Actual (E-mail)'" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Uso de un index especifico
Date: 2004-09-09 01:33:50
Message-ID: 000301c4960d$0ff59330$fc96a8c0@ggarcia
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

ok. Alvaro
Gracias ahi, va mi diseno de registro con algunos indicen.
Entonces cuando yo dese ralizar una busqueda y necesite utilizar alguno de
los indices es que necesito ver como lo puedo hacer.
Esta es una tabla donde ingreso los comprobantes que emito de cada cliente
por empresa, ahi en algunas oportunidades necesito realizar una busqueda de
algun cliente, o un numero especifico de documento
(empresa,nro.doc,serie,nro.correlativo)

Gracias nuevamente.

CREATE TABLE dba.vn_comprobantes
(
empresa_id numeric(3,0) NOT NULL,
linea_negocio char(5) NOT NULL,
doc_id char(4) NOT NULL,
serie char(3) NOT NULL,
nrodoc char(10) NOT NULL,
cierre_id numeric(6,0) NOT NULL,
fecha_emision fecha NOT NULL,
contrato_id char(10) NOT NULL,
abonado_id char(8) NOT NULL,
moneda_id int NOT NULL,
tipo_cambio int10_4 NOT NULL,
signo numeric(1,0) NOT NULL,
base_afecta decimal_14_4 NOT NULL,
base_inafecta decimal_14_4 NOT NULL,
neto decimal_14_4 NOT NULL,
igv decimal_14_4 NOT NULL,
total decimal_14_4 NOT NULL,
saldo decimal_14_4 NOT NULL,
importe_mn decimal_14_4 NOT NULL,
importe_me decimal_14_4 NOT NULL,
deuda_anterior decimal_14_4 NOT NULL,
fecha_vencimiento fecha NOT NULL,
fecha_cancelacion fecha NULL,
estado char(1) NOT NULL,
situacion char(1) NOT NULL,
division_id char(5) NOT NULL,
serie_referencia char(3) NOT NULL,
nro_referencia char(10) NOT NULL,
observaciones char(60) NOT NULL,
factura_ruc_nro char(8) NOT NULL,
usuario_id char(10) NOT NULL,
fh_auditoria datetime NOT NULL,
secuencia varchar(30) NOT NULL,
wiesse_2 varchar(20) NOT NULL,
credito varchar(20) NOT NULL,
continental varchar(20) NOT NULL,
doc_referencia char(4) NOT NULL,
item_referencia numeric(6,0) NOT NULL,
doc_padre char(4) NOT NULL,
serie_padre char(3) NOT NULL,
nro_padre char(10) NOT NULL,
fecha_padre datetime NULL,
consumo_desde datetime NOT NULL,
consumo_hasta datetime NOT NULL,
nodo_id char(6) NULL,
nvo_numero char(10) NULL,
ant_numero char(10) NULL,
nva_serie char(3) NULL,
ant_serie char(3) NULL,
nva_fecha_emision datetime NULL,
ant_fecha_emision datetime NULL,
cobrador_id char(8) NULL,
no_mora int NULL,
cuota decimal(14,4) NULL,
comision decimal(14,4) NULL,
cuotas decimal(14,4) NULL,
ubicacion int NULL,
moras decimal_14_4 NULL,
dias_vencidos decimal(4,0) NULL,
CONSTRAINT vn_comprob_15297725071 PRIMARY KEY CLUSTERED
(empresa_id,linea_negocio,doc_id,serie,nrodoc),
FOREIGN KEY (cierre_id) REFERENCES dbo.vn_cierres (cierre_id),
CONSTRAINT vn_comprob_1631344876 FOREIGN KEY (abonado_id) REFERENCES
dbo.vn_abonados (abonado_id),
CONSTRAINT vn_comprob_1647344933 FOREIGN KEY (moneda_id) REFERENCES
dbo.gn_monedas (moneda_id),
CONSTRAINT vn_comprob_1679345047 FOREIGN KEY (usuario_id) REFERENCES
dbo.ad_usuarios (usuario_id),
CONSTRAINT vn_comprob_1695345104 FOREIGN KEY (empresa_id,division_id)
REFERENCES dbo.gn_divisiones (empresa_id,division_id),
CONSTRAINT vn_comprob_1663344990 FOREIGN KEY (empresa_id) REFERENCES
dbo.ad_empresas (empresa_id)
)
CREATE NONCLUSTERED INDEX idx_2
ON
dbo.vn_comprobantes(empresa_id,linea_negocio,doc_referencia,serie_referencia
,nro_referencia,item_referencia)
go
CREATE NONCLUSTERED INDEX credito
ON dbo.vn_comprobantes(credito,doc_id)
go

CREATE NONCLUSTERED INDEX idx_04
ON dbo.vn_comprobantes(empresa_id,linea_negocio,fecha_emision,doc_id)

go
CREATE NONCLUSTERED INDEX idx_5
ON
dbo.vn_comprobantes(empresa_id,linea_negocio,abonado_id,contrato_id,estado)
go
CREATE NONCLUSTERED INDEX idx_7
ON
dbo.vn_comprobantes(empresa_id,linea_negocio,contrato_id,estado,fecha_vencim
iento)
go

CREATE NONCLUSTERED INDEX idx_9
ON dbo.vn_comprobantes(cierre_id,doc_id)
go
CREATE NONCLUSTERED INDEX idx_contrato
ON dbo.vn_comprobantes(contrato_id,doc_id,serie,nrodoc)
go
CREATE NONCLUSTERED INDEX idx_padre
ON
dbo.vn_comprobantes(empresa_id,linea_negocio,doc_padre,serie_padre,nro_padre
)
go
CREATE NONCLUSTERED INDEX idx_consumo
ON
dbo.vn_comprobantes(empresa_id,linea_negocio,doc_id,contrato_id,abonado_id,c
onsumo_desde)
go
CREATE NONCLUSTERED INDEX idx_ctacte
ON
dbo.vn_comprobantes(abonado_id,contrato_id,doc_id,serie,nrodoc,fecha_emision
)
go
CREATE NONCLUSTERED INDEX nuevo
ON dbo.vn_comprobantes(empresa_id,linea_negocio,doc_id,fecha_emision)
go

-----Mensaje original-----
De: pgsql-es-ayuda-owner(at)postgresql(dot)org
[mailto:pgsql-es-ayuda-owner(at)postgresql(dot)org]En nombre de Alvaro Herrera
Enviado el: Miercoles, 08 de Septiembre de 2004 08:18 p.m.
Para: Guillermo Garcia A.
CC: 'lista de PostgreSql-Actual (E-mail)'
Asunto: Re: [pgsql-es-ayuda] Uso de un index especifico

On Wed, Sep 08, 2004 at 07:58:44PM -0500, Guillermo Garcia A. wrote:
> Gracias Alvaro.
> Pero pero por favor alguien podria ser mas especifico.
> Entiendo a quien me diga que me lea los manuales, pero si alguien ha hecho
> algo similar.

Yo mismo puedo ser mucho mas especifico, si me muestras la definicion de
la tabla y los indices. No es un tema de mala voluntad, sino de contar
con los detalles necesarios.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end." (2nd Commandment for C programmers)

---------------------------(end of broadcast)---------------------------
TIP 4: No hagas 'kill -9' a postmaster

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2004-09-09 05:26:58 Re: Uso de un index especifico
Previous Message Alvaro Herrera 2004-09-09 01:17:55 Re: Uso de un index especifico