From: francescosaf <francescosaf.152kao@mail.webservertalk.com>
To: pgsql-sql@postgresql.org
Subject: problem with slow select
Date: Wed, 21 Apr 2004 10:00:23 -0500
Message-ID: <francescosaf.152kao@mail.webservertalk.com> (raw)
hi
I have two tables:
table: XXXX
idcode varchar(15) -->references (idcode) table YYYY
latitude float
longitude float
time timestamp
p_a char(1)
barcode....
address....
idprog serial... -->primary key
flag boolean
table YYYY
idfact numeric(7,0) --->references .....
idcode varchar(15) --->primary key
name varchar(20)
I want to exctract the last operation of table XXXX for each idcode of
table YYYY where idfact=123
I HAVE THIS QUERY BUT IT IS TOO SLOW (10 SECONDS):
select XXXX.*,YYYY.name from YYYY,XXXX join (select
XXXX.idcode,max(XXXX.tempo) as tempo from XXXX,YYYY where
YYYY.idfact=123 and XXXX.idcode=YYYY.idcode group by XXXX.idcode)
temptable on (temptable.tempo=XXXX.tempo and
temptable.idcode=XXXX.idcode) where YYYY.idfact=123 and
XXXX.idcode=YYYY.idcode order by YYYY.name;
PLEASE HELP ME
--
francescosaf
------------------------------------------------------------------------
Posted via http://www.webservertalk.com
------------------------------------------------------------------------
View this thread: http://www.webservertalk.com/message189539.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: francescosaf.152kao@mail.webservertalk.com
Subject: Re: problem with slow select
In-Reply-To: <francescosaf.152kao@mail.webservertalk.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox