X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 579E852AA3 for ; Sun, 24 Jul 2005 19:07:12 -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 87980-06 for ; Sun, 24 Jul 2005 22:07:08 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) by svr1.postgresql.org (Postfix) with ESMTP id CCDA652A51 for ; Sun, 24 Jul 2005 19:07:06 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 69so894369wri for ; Sun, 24 Jul 2005 15:07:09 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=WdcQhkxEVjW4Jcx0F2gyFrMi91b+hxExrfhmXfloky7dZXtVHzRJe9rcSj6JY2hCFEdCMxh8g5uEd1Ob5gQWd669LY1XHUChdUr5sv51a+0GJFwB3NV46Ok6ekrf9jP3zaTjPwEFaoDc2Yo5QJwKHeJIt04dVviKAoV1UTLIj0I= Received: by 10.54.34.7 with SMTP id h7mr1957027wrh; Sun, 24 Jul 2005 15:07:09 -0700 (PDT) Received: by 10.54.135.1 with HTTP; Sun, 24 Jul 2005 15:07:09 -0700 (PDT) Message-ID: Date: Sun, 24 Jul 2005 18:07:09 -0400 From: Pascual De Ruvo Reply-To: Pascual De Ruvo To: ricky@connexiasolutions.com Subject: Re: Counting Row Cc: pgsql-sql@postgresql.org In-Reply-To: <20050722031154.CBBCD5284E@svr1.postgresql.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1373_22799982.1122242829304" References: <20050722031154.CBBCD5284E@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.257 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/217 X-Sequence-Number: 22195 ------=_Part_1373_22799982.1122242829304 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I understand you need to count of tickets smaller than $recid given=20 [CONDITION], in that case: $sql=3D"select count(*) from [MYTABLE] where [CONDITION] and ticketnumber <= =3D"=20 .$recid ; On 7/21/05, Ricky Sutanto wrote: >=20 > Hi postgre people. Can anybody help to fix performance of my query? >=20 > Let say, I have *n* number of queue ticket. (Which I use SELECT). >=20 > Is there faster method to know where is my ticket number in queue? >=20 > I use (while in PHP script ) and count one by one until my ticket number= =20 > match with row field . >=20 > $sql=3D"select * from [MYTABLE] where [CONDITION] order by [FIELDORDER]; >=20 > $rs=3D&$ctclink->Execute($sql); >=20 > $ctr=3D1; >=20 > $pos=3D0; >=20 > while (!$rs->EOF) { >=20 > if ($rs->fields[0]=3D=3D$recid) { >=20 > $pos=3D$ctr; >=20 > break; >=20 > } else { >=20 > $ctr++; >=20 > $rs->MoveNext(); } >=20 > } >=20 > print $pos >=20 > is there any method to do that with simple?? >=20 > *Thanks,* >=20 > ------=_Part_1373_22799982.1122242829304 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I understand you need to count of tickets smaller than $recid given [CONDIT= ION], in that case:

$sql=3D"select count(*) from [MYTABLE] where [CONDITION] and= ticketnumber <=3D" .= $recid  ;


On 7/21/05, Ricky Sutanto <ri= cky@connexiasolutions.com> wrote:

 

Hi postgre people. Can anybody help to fix performance of my query?

 

Let say, I have n= number of queue ticket. (Which I use SELECT).

Is there faster method to know where is my ticket number in queue?

 

I use (while in PHP script ) and  count one by one until my ticket number match with row  field .

 

$sql=3D"select * from [MYTABLE] where [CONDITION] order by [FIELDORDER];

$rs=3D&$ctclink->Execute($sql);

$ctr=3D1;

$pos=3D0;

  

   while (!$rs->EOF) {

      if ($rs->fields[0]=3D=3D$recid) {

        $pos=3D$ctr;=

        break;

      } else {

      $ctr++;

      $rs->MoveNext();  }

    }

 

   print $pos

 

 

is there any method to do that with simple??

 

Thanks,

 


------=_Part_1373_22799982.1122242829304--