Hi,
>It works, but you should use a recent version:

>test=*# select count(1) over (), i from foo;
> count | i
>-------+----
>     8 |  1
>     8 |  2
>     8 |  3
>     8 |  6
>     8 |  7
>     8 |  9
>     8 | 13
>     8 | 14
>(8 rows)

> test=*# select version();
>                                                version
> 
--------------------------------------------------------------------------------------------------------
>  PostgreSQL 8.4.2 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.3.real
> (Debian 4.3.2-1.1) 4.3.2, 64-bit
> (1 row)

Thank you for setting that right. Apologies for not checking version.
Is this approach better compared to 
postgres=# select * from (select count(*) from people ) p, (select 
firstname from people)p2;
 count | firstname
-------+-----------
     5 | Mary
     5 | Mary
     5 | John
     5 | John
     5 | Jacob
(5 rows)
This gives me
postgres=# explain  select * from (select count(*) from people )as p, 
(select firstname from people)p2;
                             QUERY PLAN
---------------------------------------------------------------------
 Nested Loop  (cost=14.00..30.42 rows=320 width=226)
   ->  Aggregate  (cost=14.00..14.01 rows=1 width=0)
         ->  Seq Scan on people  (cost=0.00..13.20 rows=320 width=0)
   ->  Seq Scan on people  (cost=0.00..13.20 rows=320 width=218)

Since I don't have 8.4, I am not in a position to do explain on that 
version. My guess - over () will be better. My query does sequential 
scans/nested loop...(if there are no indexes)

Regards,
Regards,
Jayadevan
DISCLAIMER:   "The information in this e-mail and any attachment is intended 
only for the person to whom it is addressed and may contain confidential and/or 
privileged material. If you have received this e-mail in error, kindly contact 
the sender and destroy all copies of the original communication. IBS makes no 
warranty, express or implied, nor guarantees the accuracy, adequacy or 
completeness of the information contained in this email or any attachment and 
is not liable for any errors, defects, omissions, viruses or for resultant loss 
or damage, if any, direct or indirect." 

Reply via email to