pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ricky Sutanto <ricky@connexiasolutions.com>
To: pgsql-sql@postgresql.org
Subject: Counting Row
Date: Thu, 21 Jul 2005 17:33:32 +0700
Message-ID: <20050721103304.2209252B23@svr1.postgresql.org> (raw)

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="select * from [MYTABLE] where [CONDITION] order by [FIELDORDER];

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

$ctr=1;

$pos=0;

   

   while (!$rs->EOF) {

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

        $pos=$ctr;

        break;

      } else {

      $ctr++;

      $rs->MoveNext();  }

    }

 

   print $pos

 

 

is there any method to do that with simple??

 

Thanks,

 

view thread (4+ messages)  latest in thread

Message-ID: <20050721103304.2209252B23@svr1.postgresql.org>
Permalink:  ../20050721103304.2209252B23@svr1.postgresql.org/
Also on:    postgresql.org/message-id/20050721103304.2209252B23@svr1.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ricky@connexiasolutions.com
  Subject: Re: Counting Row
  In-Reply-To: <20050721103304.2209252B23@svr1.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox