Hi all,
I have two tables MOVIMENTAZIONI with 7650 rows
CAPI with 7650 rows, when I try to join this two tables PostgreSQL
takes more than 107 minutes to retrieve rows,
the same query in:
I have installed Oracle-8 and Informix-se in the same computer
and the same query takes:
- Informix about 6 seconds.
- Oracle about 2 seconds.
I tried it also in:
- M$-Access about 3 seconds.
I'm sure this is not a vaccum problem because I executed vacuum before
I ran the query.
CREATE TABLE capi ( matricola CHAR(15) NOT NULL, specie CHAR(2) NOT
NULL, nascita DATE, sesso CHAR(1) DEFAULT 'F', razza
CHAR(3), madre CHAR(15), padre CHAR(15), azienda_origine
CHAR(08), fiscale_origine CHAR(16), paese_origine CHAR(03), iscritto
BOOLEAN, data_aggiornamento TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (matricola,specie)
);
CREATE TABLE movimentazioni ( azienda CHAR(11) NOT NULL, specie CHAR(2)
NOT NULL, matricola CHAR(15) NOT NULL, data_introduzione DATE NOT NULL,
tipo_introduzione CHAR(2), azienda_provenienza CHAR(8), fiscale_provenienza CHAR(16),
matricola_precedente CHAR(15), data_applicazione DATE, data_uscita DATE,
ragione_uscita CHAR(1), tipo_destinazione CHAR(1), azienda_destinazione CHAR(8),
fiscale_destinazione CHAR(16), paese_destinazione CHAR(3), Mattatoio CHAR(19),
n_proprietario INTEGER, data_aggiornamento TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY
(azienda,matricola,specie,data_introduzione) );
$ psql -c 'vacuum'
VACUUM
$ time psql -f test.sql 2>/dev/null >/dev/null
SELECT movimentazioni.azienda
FROM movimentazioni,capi
where ((capi.matricola = movimentazioni.matricola )
and (capi.specie = movimentazioni.specie ) );
real 107m48.354s
user 0m1.140s
sys 0m0.040s
Informix-se:
real 0m6.348s
user 0m2.250s
sys 0m0.140s
Oracle-8:
real 0m2.118s
user 0m0.780s
sys 0m0.120s
This is my environment:
- [PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3]
- Pgsql snapshot Apr 15 17:42
- postmaster -i -o -F -B 512 -S
- Linux 2.0.36 Debian
- cpu: 586
- model: Pentium MMX
- vendor_id: GenuineIntel
- RAM: 63112
- Swap: 102812
I tried the same query in v6.4 with best results.
real 3m45.968s
user 0m0.060s
sys 0m0.160s
I tried the same query with joins inverted as:
$ psql -c 'vacuum'
VACUUM
$ time psql -f test.sql 2>/dev/null >/dev/null
SELECT movimentazioni.azienda
FROM movimentazioni,capi
where (capi.specie = movimentazioni.specie )
and ((capi.matricola = movimentazioni.matricola ))
real 0m4.312s
user 0m1.220s
sys 0m0.090s
PostgreSQL version 6.4:
real 0m0.600s
user 0m0.130s
sys 0m0.030s
I thougth v6.5 was faster than v6.4
Any ideas?
Jose'