X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 947F7D1B23C for ; Mon, 28 Jun 2004 00:26:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21027-01 for ; Mon, 28 Jun 2004 03:26:15 +0000 (GMT) Received: from bill.fefferman.org (dsl081-139-018.chi1.dsl.speakeasy.net [64.81.139.18]) by svr1.postgresql.org (Postfix) with ESMTP id 5D823D1B233 for ; Mon, 28 Jun 2004 00:26:13 -0300 (ADT) Received: from billnotebook ([192.168.1.21]) by bill.fefferman.org with Microsoft SMTPSVC(6.0.3790.0); Sun, 27 Jun 2004 22:26:14 -0500 From: "Bill" To: Subject: Query performance Date: Sun, 27 Jun 2004 22:26:19 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C45C95.C4BA4240" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcRcv5muswl0fDZXQhqcyfGmT78eHw== Message-ID: X-OriginalArrivalTime: 28 Jun 2004 03:26:14.0421 (UTC) FILETIME=[AA9E0C50:01C45CBF] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200406/268 X-Sequence-Number: 7326 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C45C95.C4BA4240 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Actually, I have some queries that are slow, however I was wondering if you could help me write a query that is rather simple, but I, as a true database novice, can't seem to conjure. So we have stocks, as I have previously said, and I have a huge table which contains all of the opening and closing prices of some stocks from each day. What I like to do, in English, for each stock in each day is find a ratio: abs(closing-opening)/opening. Then I would like to average all of the ratios of each day of each individual stock together to find a final ratio for each stock, then I would like to find the highest average, to find the best performing stock. So what query can I use, and (as is appropriate for this group), how can it be optimized to run the fastest? ------=_NextPart_000_0001_01C45C95.C4BA4240 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

Actually, I have some queries that are slow, however I was wondering if you could help me write a query that is rather simple, but I, as a true database novice, can't seem to conjure.  So we have stocks, as I have previously said, and I have a h= uge table which contains all of the opening and closing prices of some stocks from ea= ch day.  What I like to do, in English, for each stock in each day is fin= d a ratio: abs(closing-opening)/opening.  Then I would like to average all= of the ratios of each day of each individual stock together to find a final ratio = for each stock, then I would like to find the highest average, to find the best performing stock.  So what query can I use, and (as is appropriate for= this group), how can it be optimized to run the fastest?

 

------=_NextPart_000_0001_01C45C95.C4BA4240--