Re: [SQL] SELECT Aggregate

2006-06-29 Thread Richard Broersma Jr
> Well whatdyaknow?? Being a Postgres newbie I hadn't even played with indexes > yet. They're awesome!! > Using Richard's suggestion of the Sub-Select in the COLUMN list, combined > with adding some indexes, I can now return this in under 5 seconds! Also, another way to improve preformance will be

Re: [SQL] SELECT Aggregate

2006-06-29 Thread Phillip Smith
sno   ON soh_product   USING btree   (soh_num);     -Original Message- From: Richard Broersma Jr [mailto:[EMAIL PROTECTED] Sent: Friday, 30 June 2006 10:51 To: Phillip Smith; pgsql-sql@postgresql.org Subject: Re: [SQL] SELECT Aggregate   > I've tried Aaron's suggestion

Re: [SQL] SELECT Aggregate

2006-06-29 Thread Richard Broersma Jr
> I've tried Aaron's suggestion of the GROUP BY and I don't know much about > it, but it ran for around 17 hours and still going (it had a dedicated Dual > Xeon 3.0GHz box under RHEL4 running it!) Maybe, this query that you are trying to run is a good candidate for a "Materialize View". http://ar

Re: [SQL] SELECT Aggregate

2006-06-29 Thread Phillip Smith
: Friday, 30 June 2006 01:25 To: Richard Broersma Jr Cc: Phillip Smith; pgsql-sql@postgresql.org Subject: Re: [SQL] SELECT Aggregate   I am not familiar enough with how postgres optimizes the queries but won't this end up with total number of queries run on DB = 1 query + 1 query/row in

Re: [SQL] SELECT Aggregate

2006-06-29 Thread Aaron Bono
I am not familiar enough with how postgres optimizes the queries but won't this end up with total number of queries run on DB = 1 query + 1 query/row in first queryWhat would be more efficient on a large database - a query like Richard submitted (subquery in the select) or one like I submitted (joi

Re: [SQL] SELECT Aggregate

2006-06-28 Thread Richard Broersma Jr
> > SELECT trans_no, > > customer, > > date_placed, > > date_complete, > > date_printed, > > ord_type, > > ord_status, (select SUM(sell_price) -- this syntax working for me. see below f

Re: [SQL] SELECT Aggregate

2006-06-28 Thread Richard Broersma Jr
> SELECT trans_no, > customer, > date_placed, > date_complete, > date_printed, > ord_type, > ord_status, select ( SUM(sell_price) from soh_product

Re: [SQL] SELECT Aggregate

2006-06-28 Thread Aaron Bono
I would recommend against using a function.  If you are selecting a large number of rows, the function will run for each row returned and will have to do a select for each row.  So if you get 1000 rows returned from your query, you will end up with 1001 select statements for your one query. Assumin

[SQL] SELECT Aggregate

2006-06-28 Thread Phillip Smith
Hi all, I have two tables which are storing all our sales orders / invoices as below. sales_order.trans_no and soh_product.soh_num are the common columns. This is PostgreSQL 8.1.4 (ie, the latest release)   We have some issues that I’ve been able to identify using this SELECT: SELECT