Re: Pregunta sobre indices

From: Alberto Cardenas Cardenas <alberto(dot)cardenas(dot)c(dot)68(at)gmail(dot)com>
To: Edwin Quijada <listas_quijada(at)hotmail(dot)com>
Cc: Herman Estaban <hermanestaban(at)gmail(dot)com>, Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar>, Alberto Cuevas <betocuevas(dot)net(at)gmail(dot)com>, pgsql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Pregunta sobre indices
Date: 2016-07-27 15:24:51
Message-ID: CA+UBRzOGMFM9_oXDYv6qCrXeCWwU5PKp_0i3ev-W_hNCfNgUGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

El tema de los indices es relativo, debes crear indices donde realmente
necesites . Normar una tabla no implica necesariamente crear indices a
diestra y siniestra

Para saber si necesitas un indice o no, primero debes tener clara la query,
hacer un explain y dependiendo del resultado de ese explain recien ver si
necesitas un indice o no.

Si tienes 100 registros en una tabla (por ejemplo) y una consulta va a
traer 90 de estos, dudo mucho que al optimizador considere utilizar algun
indice

Saludos

El 26 de julio de 2016, 14:35, Edwin Quijada <listas_quijada(at)hotmail(dot)com>
escribió:

> LO primero es porque no poner los nombres completos y no usar
> abreviaciones de los campos?
>
>
>
>
> ------------------------------
> *From:* pgsql-es-ayuda-owner(at)postgresql(dot)org <
> pgsql-es-ayuda-owner(at)postgresql(dot)org> on behalf of Herman Estaban <
> hermanestaban(at)gmail(dot)com>
> *Sent:* Thursday, June 23, 2016 5:48 PM
> *To:* Gerardo Herzig; Alberto Cuevas
> *Cc:* pgsql
> *Subject:* Re: [pgsql-es-ayuda] Pregunta sobre indices
>
> Hola, aprovechando el hilo.Les comento mi caso, existe una tabla en una
> base de datos SQL Server de nombre SFT_MAEPROD en la que se almacena la
> informacion de los productos que vende la empresa (ropa).
>
> Esta tabla tenie mas de 100 campos y no esta normalizada, en verdad todas
> las tablas de esta base de datos en SQL Server no estan normalizadas.
>
> Se esta creando una nueva base de datos en PostgreSQL para dejar de usar
> ya el SQL Server.
>
> Una vez que se termine de hacer la migración de información de SQL Server
> a PostgreSQL, tendre que armar consultas y reportes (JOINS) con distintos
> tipos de filtros, necesitare indices para tener un tiempo de respuesta
> favorable
>
> He normalizado esta tabla SFT_MAEPROD en PostgreSQL, y he pensado crear
> indices, mi idea es que quede asi:
>
> CREATE TABLE public.sft_maesede (
> id_sft_sede serial NOT NULL PRIMARY KEY, -->id sede
> nom_sft_sede varchar(50), --nombre sede
>
> CREATE TABLE public.sft_maealma (
> id_sft_alma serial NOT NULL PRIMARY KEY, --> id almacen
> id_sft_sede integer NOT NULL, --id sede ----> (CREAR INDICE)
> nom_sft_alma varchar(50), --nombre almacen
>
> CREATE TABLE public.sft_maeprod (
> id_sft_prod bigserial NOT NULL PRIMARY KEY, -->id producto
> id_sft_fami integer NOT NULL, --id familia ----> (CREAR
> INDICE)
> id_sft_clas integer NOT NULL, --id clase ----> (CREAR
> INDICE)
> id_sft_mode integer NOT NULL, --id modelo ----> (CREAR INDICE)
> id_sft_line integer NOT NULL, --id linea ----> (CREAR
> INDICE)
> id_sft_mate integer NOT NULL, --id material ----> (CREAR INDICE)
> id_sft_colo integer NOT NULL, --id color ----> (CREAR
> INDICE)
> id_sft_tall integer NOT NULL, --id talla ----> (CREAR
> INDICE)
> id_sft_temp integer NOT NULL, --id temporada ----> (CREAR INDICE)
> id_sft_gene integer NOT NULL, --id genero ----> (CREAR INDICE)
> id_sft_pres integer NOT NULL, --id presentacion ----> (CREAR
> INDICE)
> nom_stf_prod varchar(100), --nombre producto ----> (CREAR
> INDICE)
>
> CREATE TABLE public.sft_prodxalm (
> id_sft_codi bigserial NOT NULL PRIMARY KEY, --> id
> id_sft_sede integer NOT NULL, --id sede ----> (CREAR
> INDICE)
> id_sft_alma integer NOT NULL, --id almacen ----> (CREAR INDICE)
> id_sft_prod bigint NOT NULL, --id producto ----> (CREAR
> INDICE)
>
> Estoy en lo correcto?,
>
> Espero sus comentarios.
>
> Saludos.
>
>

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alberto Cardenas Cardenas 2016-07-27 15:35:47 Estadisticas de base de datos y archivo de configuracion
Previous Message Guillermo E. Villanueva 2016-07-27 12:12:15 Re: hash