| From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
|---|---|
| To: | Vida Luz Arista <vlal(at)ideay(dot)net(dot)ni> |
| Cc: | pgsql-admin(at)postgresql(dot)org |
| Subject: | Re: Query |
| Date: | 2001-08-24 16:09:55 |
| Message-ID: | Pine.BSF.4.21.0108240904330.22775-100000@megazone23.bigpanda.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
On Fri, 24 Aug 2001, Vida Luz Arista wrote:
> Hi All, I have two questions
>
> 1- I have a query but this is very slow, I need to acelerate the
> consult, this result sill be show in the web.
>
> My query is:
>
> select user, descripcion from client where login not in (select
> distinct(usr_cliente) from conexion where fecha between '$date_begin' and
> '$date_end') order by user"
See FAQ entry 4.23. Short form is convert the query to use EXISTS rather
than IN.
> 2- I made this function:
>
> CREATE FUNCTION list(date,date) RETURNS user
> AS 'select distinct(usr_cliente) from conexion where fecha between
> $date_begin and $date_end' LANGUAGE 'sql';
>
> When I execute a query to this function like:
> select select listado('08-10-2001', '08-13-2001') as user;
>
> the result is just 1 row, however If I to execute the query this return
> 300 rows, why the function only return one row?
I think you'd need to say setof user as the return type, although I'm not
100% sure that'll give you back something meaningful (It gives me
something meaningful on my 7.2 devel machine, but I don't have an earlier
system to test on)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ted Rolle | 2001-08-24 21:49:32 | Fast load |
| Previous Message | Richard Bayet | 2001-08-24 15:59:32 | Re: Query |