Re: what's quicker: pg_result or pg_numrows

From: Date: Mon, 18 Dec 2000 19:11:16 +0000
Subject: Re: what's quicker: pg_result or pg_numrows
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-30884@lists.php.net to get a copy of this message
Matt Friedman wrote: > > If your database implementation ( I don't recognize the "pg" functions you > are calling) supports the num_rows function then it has already calculated It's PostgreSQL. > this info even if you don't ask for it. So, it's probably a matter of > convenience, rather than speed. Probably fine to call the num_rows function, > that is. > > However, not all db implementations have a num rows function. Instead, you > have to formulate a query like so: "SELECT COUNT(*) AS num_results FROM... You mean, that's what PHP would do if PostgreSQL doesn't have a num_rows function to implement pg_numrows() (wouldn't know where to look for this info off the top of my head)? Execute this query to get the number of rows? That's precisely what I am afraid of. > Then, num_results will be your number of rows(generally, group by functions > are different). This method will travel across implementations whereas the > num_rows method may not. > > Of course, none of this matters to you unless you are using a database > abstraction layer like in phplib or something like that. Nope, ain't usin' any of that. Cheers, Frank

« previous php.general (#30884) next »