From: | greg(at)turnstep(dot)com |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Four questions |
Date: | 2003-02-20 16:23:10 |
Message-ID: | df2e6d458067c076fd122d0d71623d3f@biglumber.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> hmm, this select its very big select, including many tables and
> throught func. Making this same query 2 times is without any sens,
> pointless. I make this select trought libpq, from server to others PC, and
> every Exec need same time, and befor dowloading rows to client memory i
> need to know exacly how big is select .... :/
There is no way to know how many rows a query is until you actually run the
query. A DECLARE statement does not actually run the query. Why not set aside
memory for a specific amount of rows and FETCH with a number as suggested?
> For example i do select and i dont know name of the cols, but i
> know type, and count of cos, and i want to do what i can do with ORDER
> : select * from func() where [1] != NULL order by 1;
> [1] == name of first col in this selec
Sorry, you cannot do it like that, you must specify the actual column, not the
alias, inside of the WHERE clause. If your column is an expression, you will
have to repeat that expression in the WHERE clause as well:
SELECT a+b as "abba", c, d FROM mytable WHERE c=12 AND a+b < 10 ORDER BY 1;
or..
SELECT a+b as "abba", c, d FROM mytable WHERE c=12 AND a+b < 10 ORDER BY a+b;
or..
SELECT a+b as "abba", c, d FROM mytable WHERE c=12 AND a+b < 10 ORDER BY "abba";
I prefer the last one, as the alias name in the ORDER BY is clearer than the
number and less likely to cause future problems when you change "abba" inside
of the select.
> ...then i can use same func like other user ?
Yes. :)
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200302201119
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html
iD8DBQE+VQAjvJuQZxSWSsgRAiZ4AJ4lfk4mM3b72r79ydRHKH9qzr/oiwCdE1hw
kxErBUEoquUVG/3lzUcjqKs=
=1d5S
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Arunachalam Jaisankar | 2003-02-20 16:40:02 | How to drop all the sequences |
Previous Message | Stephan Szabo | 2003-02-20 16:05:46 | Re: 7.3.1 takes long time to vacuum table? |