Re: Problema Order By en PosgreSQL 8.1

From: "Paolo Lopez" <murphyperu(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Problema Order By en PosgreSQL 8.1
Date: 2006-04-07 20:42:19
Message-ID: ab97ec200604071342j16feab0fj6f124420da8ee77e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-es-ayuda

Alvaro:

>
> Por favor prueba lo siguiente: crea la tabla y agrega los resultados,
> tal como lo hiciste antes. Ejecuta VACUUM ANALYZE tablita, y despues
>
> SET enable_seqscan TO off;
> y prueba nuevamente la consulta.

Me salé:

Paul2=# select tablita.idDia , tablita.numHora
Paul2-# from tablita
Paul2-# WHERE tablita.campoA = 1 AND
Paul2-# tablita.campoB =1 AND
Paul2-# tablita.campoC =1 AND
Paul2-# tablita.campoD =1 AND
Paul2-# tablita.campoE = 1
Paul2-# ORDER BY tablita.idDia , tablita.numHora;
iddia | numhora
-------+---------
1 | 1
1 | 2
1 | 3
1 | 4
1 | 5
1 | 6
1 | 7
1 | 8
2 | 1
2 | 2
2 | 3
2 | 4
2 | 5
2 | 6
2 | 7
2 | 8
3 | 1
3 | 2
3 | 3
3 | 4
3 | 5
3 | 6
3 | 7
3 | 8
4 | 1
4 | 2
4 | 3
4 | 4
4 | 5
4 | 6
4 | 7
4 | 8
5 | 1
5 | 2
5 | 3
5 | 4
5 | 5
5 | 6
5 | 7
5 | 8
(40 rows)

> Envia el EXPLAIN ANALYZE, y verifica

El EXPLAIN salé :

Sort (cost=2.96..3.06 rows=40 width=8) (actual time=0.338..0.375
rows=40 loops=1)
Sort Key: iddia, numhora
-> Seq Scan on tablita (cost=0.00..1.90 rows=40 width=8) (actual
time=0.028..0.188 rows=40 loops=1)
Filter: ((campoa = 1) AND (campob = 1) AND (campoc = 1) AND
(campod = 1) AND (campoe = 1))
Total runtime: 0.501 ms

> si el orden es correcto o no.

el orden es correcto :)

>
> Luego: borra el indice. ALTER TABLE tablita DROP PRIMARY KEY.

borrado constraint

tablita_pkey PRIMARY KEY (campoA, campoB, campoC, campoD, campoE,
campoF, iddia, numhora);

> Luego
> crealo de nuevo: ALTER TABLE tablita ADD PRIMARY KEY ( ... )

creando:

ALTER TABLE ONLY tablita
ADD CONSTRAINT tablita_pkey PRIMARY KEY (campoA, campoB, campoC,
campoD, campoE, campoF, iddia, numhora);

> Luego
> SET enable_seqscan TO off;
> y la consulta otra vez; pega el EXPLAIN ANALYZE

me salé :

Sort (cost=2.96..3.06 rows=40 width=8) (actual time=0.330..0.368
rows=40 loops=1)
Sort Key: iddia, numhora
-> Seq Scan on tablita (cost=0.00..1.90 rows=40 width=8) (actual
time=0.026..0.184 rows=40 loops=1)
Filter: ((campoa = 1) AND (campob = 1) AND (campoc = 1) AND
(campod = 1) AND (campoe = 1))
Total runtime: 0.491 ms

> e indica si el resultado
> es correcto o no.
>

me sale correcto :)

Paul2=# select tablita.idDia , tablita.numHora
Paul2-# from tablita
Paul2-# WHERE tablita.campoA = 1 AND
Paul2-# tablita.campoB =1 AND
Paul2-# tablita.campoC =1 AND
Paul2-# tablita.campoD =1 AND
Paul2-# tablita.campoE = 1
Paul2-# ORDER BY tablita.idDia , tablita.numHora;
iddia | numhora
-------+---------
1 | 1
1 | 2
1 | 3
1 | 4
1 | 5
1 | 6
1 | 7
1 | 8
2 | 1
2 | 2
2 | 3
2 | 4
2 | 5
2 | 6
2 | 7
2 | 8
3 | 1
3 | 2
3 | 3
3 | 4
3 | 5
3 | 6
3 | 7
3 | 8
4 | 1
4 | 2
4 | 3
4 | 4
4 | 5
4 | 6
4 | 7
4 | 8
5 | 1
5 | 2
5 | 3
5 | 4
5 | 5
5 | 6
5 | 7
5 | 8
(40 rows)

>
> Me gustaria saber si alguien mas puede reproducir este problema en
> Windows.
>
> --
> Alvaro Herrera http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>

Paolo.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Juan Carlos Badillo Goy 2006-04-07 21:28:43 Problema con la Salva y Restaura en PosgreSQL 8.0
Previous Message Alex Concha 2006-04-07 20:27:04 Re: Problema Order By en PosgreSQL 8.1

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message ernesto contreras 2006-04-07 21:06:16 Re: Ayuda para Importar datos de Oracle a Postgres
Previous Message Alex Concha 2006-04-07 20:27:04 Re: Problema Order By en PosgreSQL 8.1