Re: Four questions
От | greg@turnstep.com |
---|---|
Тема | Re: Four questions |
Дата | |
Msg-id | df2e6d458067c076fd122d0d71623d3f@biglumber.com обсуждение исходный текст |
Ответ на | Re: Four questions (owner <ivan@psycho.pl>) |
Список | 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@turnstep.com PGP Key: 0x14964AC8 200302201119 -----BEGIN PGP SIGNATURE----- Comment: http://www.turnstep.com/pgp.html iD8DBQE+VQAjvJuQZxSWSsgRAiZ4AJ4lfk4mM3b72r79ydRHKH9qzr/oiwCdE1hw kxErBUEoquUVG/3lzUcjqKs= =1d5S -----END PGP SIGNATURE-----
В списке pgsql-general по дате отправления: